Move to X, not Y

spicklspickl Member Posts: 7
edited February 2012 in Working with GS (Mac)
I'm currently working on an enemy AI for my platformer game, and I want the enemy to move to the player's X position once the player is in a certain range. Now, I've got the radius thing set up, but struck a problem when making the enemy move to the player's X pos. How do I make the enemy gradually move to the Player's X Position without going to a specific Y Position?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi @spickl

    Using the X position of the player but the enemy's own Y position will do it. :-)

    ----------------------------------------------------------------------------
    iPad app: End of the Earth –•– http://davidgriffinapps.co.uk/
    ----------------------------------------------------------------------------

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • spicklspickl Member Posts: 7
    edited February 2012
    @gyroscope Thanks, but gravity now no longer affects the enemy :\
  • spicklspickl Member Posts: 7
    @gyroscope Also, the enemies stop when they've reached the player even though I didn't check "Run to completion"
  • simo103simo103 Member, PRO Posts: 1,331
    @spicki .. what rules and behaviors do you have to move the enemy?
  • spicklspickl Member Posts: 7
    @simo103 Just a rule that says "If attribute "Player-is-within-reach" = 1, Move to "PlayerX", "Enemy.Position.Y"
    But the thing is, he'll stop when he reachers the player every time I enter his detection radius, even though I unchecked "Run to completion". Very odd. Also, when he moves down (falls down basically) gravity won't affect it because he's moving down with the same speed as his x-speed when he's moving towards the player (currently at 300)
  • simo103simo103 Member, PRO Posts: 1,331
    @spickl .. bare with me as I'm trying to understand what you're trying to do.
    1. When the Player moves to a certain point and an enemy is within-reach you want the Enemy to move to the Player's X position and then stop?
    2. If an enemy is moving (because Player-is-within-reach) but he reaches the end of a platform you want the enemy to fall (not fall with movement to X)? Correct?
    In this case but in the enemy to move to the Players x at speed 300 but wrap it in the rule When Player-is-within-reach=1 AND enemy collides/overlaps with Platform. This should stop the move at the edges of the platforms and let gravity take over .. I believe.
  • spicklspickl Member Posts: 7
    @simo103 Nevermind, I fixed it with a Constrain Attribute (enemy velocity x) set to -100 or 100, depending on whether the player is at the left or right side of the enemy!
    Now I'm trying to make the player jump when he reaches an obstacle, which is really hard :(
  • simo103simo103 Member, PRO Posts: 1,331
    @spickl .. no problem .. glad your fixed. If you need something to dig thru re: jumping .. take a look at this thread and look further down in the posts as jump/double jump demo was added to POM's great mega demo pack: http://forums.gamesalad.com/discussion/38132/gs-tool-box-a-free-mega-template-ready-now/p1
Sign In or Register to comment.