Make actor follow player
khashai
Member Posts: 6
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!
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
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
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!
It is almost as though they are not actually registering the player's position, or that they are registering the wrong values.