Spawn new actor to move/chase main actor

dimps620dimps620 Member Posts: 49
edited January 2012 in Working with GS (Mac)
Can someone give me an idea of how to spawn a new actor that will chase or move in the direction of main actor in game? I would like to have the new actor/actors randomly spawn on the screen and chase the main charachter. In the higher levels it will spawn more actors and their speed will increase an be able to catch the main player actor.

Are there paths in gamesalad? By this I mean that an actor will continually move back and forth or up and down or a combinaton of both in a set pattern?

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,271
    edited January 2012
    Hi,

    I believe this should work...
    Create an attribute called FollowX and FollowY (integer)
    in your character actor:
    At the very beginning of the actor put a change attribute: self.positionX to game.followX. Do the same thing just this time for Y, change attribute self.positionY to followY

    Spawn actor: Bad guy (whatever the name is for the actor you want to follow your main character)
    X: random(Blah,Blah) Y: Random(blah,Blah) Figure out the min and max for both X and Y cords and put those in place of the Blahs.

    Then, in the bad guy actor:
    move to or accelerate toward behavior,
    For X put in game.FollowX and for Y put in game.FollowY. This should work.
    Then just set the speed and you should be good to go.

    Anybody correct me if i'm wrong.
  • jckmcgrawjckmcgraw Member Posts: 647
    @dimps620 Answer to your first question...

    You will need two real game attributes. Call one of them playerX and the other playerY

    Go into your main actor, and drag 2 change attributes on the screen

    The first one will be: change playerX to self.position.x
    As you can guess the 2nd one will be: playerY to self.position.y

    Now go into the actor that you want to spawn randomly. Drag on the move-to attribute, and tell it to move to playerX, and playerY.

    Sorry, but I haven't figured out the random spawning. Look around youtube... I remember seeing a tutorial on that there.

    Hope this helps.
  • dimps620dimps620 Member Posts: 49
    Thanks. This will give me something to work on.
  • Braydon_SFXBraydon_SFX Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,271
    Whoops,
    I guess use real attributes like Jckmcgraw said instead of integers.
Sign In or Register to comment.