Actor not knowing he is moving some directions.

SxarcisiousSxarcisious Member Posts: 45
edited December 2011 in Working with GS (Mac)
So I have and actor that chases the main actor. This works with no probs. Now I have tried to have the actor who is chasing to know which direction he is going by having a number appear at different angles when he changes directions. For some reason only 4 of the directions display the number correctly. When going Sw,S,Se,E the number appears. When going Ne,N,Nw,W the number does not appear even though the actor moves in that direction. I have also tried animating him based on the direction and have had the same results.

I use vectorToAngle with joystick controls.

This is the actor logic

contrain - self.direction to vectorToAngle( self.Position.X - game.GoodGuysX , self.Position.Y - game.GoodGuysY )

his movement

Move to - game.GoodGuysX game.GoodGuysY speed 100 relative to scene

then I have his number appear bases on angles

N - >= 225 < 270

Ne - >= 180 < 225

E- >= 135 <180

Se- >= 90 < 135

S- >= 45 < 90

Sw- >= 0 < 45

W- >= 315 <= 360

Nw- >= 270 < 315

I have also tried using self.drection as an real,integer and angle..

I have been trying to figure it out.. Only Sw,S,Se,E work properly..


Thanks,

Comments

  • SxarcisiousSxarcisious Member Posts: 45
    edited December 2011
    Don't know why those breaks are showing up there.
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    It's 5am here and I'm knackered, so don't take what I'm about to say as anything more than a babbling fool, but flip round your math - goodguysx - self.position.x, goodguysy -self.position.y

    Also, you want it to be a real attribute.

    Ace
  • SxarcisiousSxarcisious Member Posts: 45
    Thanks, Just tested this out. It was the same results, still 4 directions don't work correctly. If you have anymore ideas id appreciate it, I am a little stumped here.
  • POMPOM Member Posts: 2,599
    Make the self.direction attribute an "angle" attribute !
    Then instead of using "move to" behavior which is broken, use the "move" behavior and in the direction of movement use your self.direction Angle attribute.

    The next is important to understand how angles work in gs:
    in your actor put a display text behavior to display your self.direction and see the values according to the direction of movement !
    Write down (accually write on paper) the values for going left,right etc , then base your rules on those values.

    Hope it will help you a bit

    Roy.
  • SxarcisiousSxarcisious Member Posts: 45
    Thanks! You have solved it for me, the display text tip is fantastic. I had been frustrated for a while trying to figure that out. I very much appreciate it!
Sign In or Register to comment.