destroying actors

Hello, I was wondering if it is possible to create a rule that basically says when actor one collides with actor 2 destroy actor 3 ?? (if that makes sense)

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Sure. You can communicate between actors by changing the value of a game attribute:

    Actor 1

    When actor collides with [actor 2]
         Change attribute game.destroy3 to true

    Actor 3

    When attribute game.destroy3 is true
         Destroy Actor

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • bob loblawbob loblaw Member, PRO Posts: 793

    or you can use tables

  • jessica.michaeljessica.michael Member, PRO Posts: 27

    @tatiang I tried that but it is not working for some reason

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Then you need to post more details, screenshots of your rules, or preferably the project file (.zip it first) so that we can figure out what you're doing wrong.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • jessica.michaeljessica.michael Member, PRO Posts: 27



  • bob loblawbob loblaw Member, PRO Posts: 793

    here's a basic quickly slapped together demo of what tatiang was saying. use left/right arrows to move actor 1.
    if you're having trouble getting the hang of gs behaviours, you should look on youtube for gshelper or jamie cross videos. great learning resources when you start out.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I assume those two rules in the screenshot are from separate actors?

    If your actors are moving too quickly or are on different layers, it may affect their ability to detect collisions. To know for sure, place a Log Debugging Statement in each actor and then open the Debugger window and watch for the expressions you entered to show up. If they don't, then the actor(s) did not register collisions.

    Provide that information as well as the way you are moving the actors (e.g. Move behavior set to 250 speed) and we'll go from there.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • jessica.michaeljessica.michael Member, PRO Posts: 27

    Okay I have attached my game so you guys can understand better. sorry for the trouble

  • bob loblawbob loblaw Member, PRO Posts: 793
    edited November 2018

    is the idea in your atached version that when the ship collides with '5', that the five disappears? because that's working. you also only need the destroy rule in the '5' actor. no need for an extra attribute to recognise it.

    if (i'm assuming) you're going to make it so that there's a randomly generated equation though, that corresponds to the number the ship hits, you'll probably need an individual actor for each number that is spawned, each with a rule within that checks if the collision based on the equation (if that makes sense).

    you also need to change your score rule to be change game.score to game.score+50, so that the score goes up each time the right number is hit.

    i hope that helps.

    edit: also once you get closer to the end stages of your game, you should look into using a program called physics body editor to make your collisions cleaner/more accurate.

  • jessica.michaeljessica.michael Member, PRO Posts: 27
    edited November 2018

    is the idea in your atached version that when the ship collides with '5', that the five disappears? >

    no what im trying to do is when the spacecraft collides with 5 to destroy the equation 2+3 and then add another equation.

  • bob loblawbob loblaw Member, PRO Posts: 793

    @jessica.michael said:

    is the idea in your atached version that when the ship collides with '5', that the five disappears? >

    no what im trying to do is when the spacecraft collides with 5 to destroy the equation 2+3 and then add another equation.

    ok. have a look at what i put in this thread https://forums.gamesalad.com/discussion/96995/random-text-in-text-box#latest
    and see if you can integrate that into your game logic.

    within each number actor, you will probably need a self.attribute (call it 'value') that aligns with the number the actor represents (ie. number 1 will have an integer attribute within itself set with the value 1). then your collision rule would for scoring would be - if [all] game.answer (the attribute from my example on the other thread) = self.attribute value and actor collides with ship - then - add to score, change the value to activate the next equation - destroy

  • jessica.michaeljessica.michael Member, PRO Posts: 27

    okay i get what your saying, but how can I change value to activate the next equation and then destroy?

  • jessica.michaeljessica.michael Member, PRO Posts: 27

    Okay, i tried my best to follow your codes however now the collisions and score isn't working. Im not sure what im doing wrong. I have reattached the file for you to look at. I I really appreciate your time in helping me thank you!

  • bob loblawbob loblaw Member, PRO Posts: 793

    @jessica.michael said:
    Okay, i tried my best to follow your codes however now the collisions and score isn't working. Im not sure what im doing wrong. I have reattached the file for you to look at. I I really appreciate your time in helping me thank you!

    no worries. i'll take a look and get back to you in a couple of days.

  • Two.ETwo.E Member Posts: 599

    Hello,

    Attached is demo I made for your game. Let me know if you have any questions. It uses a table to display questions.

    Best,
    Two.E

  • bob loblawbob loblaw Member, PRO Posts: 793

    @jessica.michael please check personal messages

Sign In or Register to comment.