Enemy pointing in the direction of player it is chasing

JCFordJCFord Member Posts: 785
edited November -1 in Working with GS (Mac)
I have an enemy chasing my player onscreen and working great but I want the enemy to point in the direction it is moving in.

I have tried different methods but just can't seem to get this right, any advice?

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Well, one thing you could do is check if the enemy linear velocity is positive or negative for both X and Y. Then create 4 different images and use a change image behavior. So if enemy is traveling "north" then linear.velocity.Y would be positive and you could have an image that goes with that. Same thing for the other three directions. Not sure about diagonal.
  • JCFordJCFord Member Posts: 785
    Hi Scitunes,

    I have that setup already and it works if the enemy is moving left, right, up or down but like you said when the enemy is moving diagonal that seems to be where its going wrong.

    So I either need a way of knowing if the enemy is moving diagonal and have a separate image for that, or having a way of rotating the enemy so its always facing the player it is chasing. I have tried the rotate to Target X and Target Y position I have located on the player its chasing but that doesn't seem to work either?
  • JCFordJCFord Member Posts: 785
    UPDATE: Just found the solution.

    I used a Rotate to position: Target X and Target Y and just wrapped it in a timer to update every 0.1 second and it works a treat!

    Thanks
  • JCFordJCFord Member Posts: 785
    I just uploaded a test of the final result:

    http://gamesalad.com/game/play/33467
Sign In or Register to comment.