Angle of direction and rotation? Am i correct?

RHRH Member Posts: 1,079
edited November -1 in Working with GS (Mac)
I really hate posting for help as I prefer to figure stuff out on my own, but after a long time searching the forums and testing ideas I can't figure it out.

I was wondering how to make an actor rotate to the direction that it is travelling. I saw vectorToAngle mentioned a lot but I'm not too sure what that does. I also guess that I will probably have to use a timer.

Am I correct in thinking that this will calculate the direction of travel:

asin( self.Motion.Linear Velocity.X / self.Motion.Angular Velocity )

I'm assuming that asin is short for arcsin or inversesin

If this is correct can I do something like this:

Timer: every 0.1 seconds

Roate to angle:asin( self.Motion.Linear Velocity.X / self.Motion.Angular Velocity )

I tried that but it didn't go too well, just rotated a bit in a direction that clearly wasn't where it was travelling and didn't do much good at all.

Any help is appreciated, Thanks

Comments

  • SingleSparqSingleSparq Member Posts: 1,339
    I too am looking for the answer to this - from an overhead position, using joystick control I want the actor to rotate and face the direction it's going. I have scoured the forums and demos but have not found the answer. Anyone?
  • SingleSparqSingleSparq Member Posts: 1,339
    SingleSparq said:
    I too am looking for the answer to this - from an overhead position, using joystick control I want the actor to rotate and face the direction it's going. I have scoured the forums and demos but have not found the answer. Anyone?

    Edit - Sorry hit the wrong button there

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    If you are using the joystick demo as a starting point the beach ball travels at the angle determined by the joystick (they call it game.angle). So all you need to do is use a constrain behavior in the main player.

    constrain self.rotation to game.angle. The player will always face in the direction the joystick is making it travel.
  • SingleSparqSingleSparq Member Posts: 1,339
    Thanks scitunes - I will give that ago.
  • ckck Member Posts: 224
    I'm looking for something similar. If a free-floating actor is travelling a particular direction (on x, based on a collision), then another actor tilts in that direction. How can I track the direction of an actor?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Constrain the rotating actor's self.rotation to a game.angle attribute. Then, any time you need to see the actors angle, just reference the game.angle attribute that data is stored in.
  • RHRH Member Posts: 1,079
    Oh, forgot about this :)

    I don't know what i was thinking when i started trying to use my maths knowledge,

    Here is what i did if anyone still (or in the future) wants to know:

    constrain attribute: self.rotation to (vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))-90
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    RH said:
    Oh, forgot about this :)

    I don't know what i was thinking when i started trying to use my maths knowledge,

    Here is what i did if anyone still (or in the future) wants to know:

    constrain attribute: self.rotation to (vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))-90

    Is this still the most efficient way of doing rotate to direction travelling? or is there a way that does not involve constrain... (I'm always trying to reduce Processor usage)...

    Although it does work perfectly (thatnks for sharing with me from the future)
Sign In or Register to comment.