Make actor follow player

khashaikhashai Member Posts: 6
edited November -1 in Working with GS (Mac)
Hello again,

OK, my latest dilemma: I have tried to follow instructions posted to these forums to get actors to move to and follow the player. Think along the lines of how the enemies behave in Gauntlet (the original).

Basically, what I believe I have done is use game attributes to update the player's X & Y position every 0.2 seconds. Then the actor that represents an enemy is set to accelerate towards the game attribute for the player's X & Y position. Unfortunately, this is not what is happening. What is happening is that the enemy actors are simply accelerating off the bottom of the screen, about maybe 100 pixels to the left of the bottom right corner. Eventually they come back onto the screen, and appear to have done a long orbit.

My problem here is that it will be absolutely necessary for the enemies to target and follow the player, in my game's design.

Additionally, the forum post I am getting my instructions from (http://gamesalad.com/forums/topic.php?id=6499#post-42916) has it's last post dated 9 months ago. So, I am guessing something changed in GS since then, or I am missing something more important here.

Anyways, help is appreciated!

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    make 2 attributes player x and player y

    in the player constrain player x to self position x and player y to self position y

    then in the enemies have a accelerate towards behavior. In that behavior for the x position put player x and for the y position put player y. and have it relative to scene
  • khashaikhashai Member Posts: 6
    JohnPapiomitis said:
    make 2 attributes player x and player y

    in the player constrain player x to self position x and player y to self position y

    then in the enemies have a accelerate towards behavior. In that behavior for the x position put player x and for the y position put player y. and have it relative to scene

    John, first off hello again, your last answer was very helpful, and while it was not exactly what I was looking for, it helped to point me in the right direction, and now I believe I have that problem all worked out.

    As for this one:

    I have the two game attributes. In the Player actor, I have the following set:
    -Group
    --Timer (Every 0.2 Seconds) Do not run to completion
    ---Constrain game.Player X to self.Position.X
    ---Constrain game.Player Y to self.Position.Y

    In the enemy actor, I have the following set:
    -Accelerate Towards: game.Player X, game.Player Y, relative to scene, acceleration: 100

    While it is unrelated (I think), I should also mention that there is a spawner on screen, which is set to spawn a maximum of 10 enemy actors. When it hits 10, it stops spawning. If the number of enemies is decreased, it will spawn again until the number hits 10. The reason I mention this is because I am unsure if the number of actors on screen has an impact on this working or not.

    Also, John: You have been a huge help so far. I am incredibly grateful. Thanks again!
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    ahh i see the problem. Tkae the timer out of the constrain behaviors and have them on there own. Constrain continously updates them so theres no need for a timer. sorry i forgot to mention that
  • khashaikhashai Member Posts: 6
    Ok, I have removed the timer from the constrain behaviors, and tested the scene. Unfortunately, it still behaves in the same way as before. The enemy actors just zip off the lower left hand side of the screen, about 100 pixels to the right (sorry I think I described this backwards the first time around).

    It is almost as though they are not actually registering the player's position, or that they are registering the wrong values.
Sign In or Register to comment.