Enemy Sprite Control

bionsubabionsuba Member Posts: 2
edited March 2012 in Working with GS (Mac)
I have an enemy that can move in all directions and I need to find some way to decide which sprite to use based on what angle the enemy is moving. I have four directional sprites, any ideas on how to implement this?

Comments

  • POMPOM Member Posts: 2,599
    edited March 2012
    The angle of the actor can be calculated using the "vector to angle" expression .
    make a self attribute call it "my angle"
    now make a constrain :
    Constrain "self.my angle" TO vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )

    This will give you the angle of your enemy's movement and you can do whatever you want with this value :)

    Photobucket Roy
  • bionsubabionsuba Member Posts: 2

    Constrain "self.my angle" TO vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )
    thank you, I tried this and it works well
Sign In or Register to comment.