How Can You Tell The Current Rotation Angle Of A Physics Object?

I’ve got a physics object that gets moved around by physics forces. I want to set a new linear impulse in it’s forward direction, but after it gets moved I don’t know which way is forward anymore.

How can I get this information?

I use this in my game:

local xForce = -math.sin( math.rad( 180 + player.rotation )) \* player.speed local yForce = math.cos( math.rad( 180 + player.rotation )) \* player.speed player:setLinearVelocity( xForce, yForce )

See if that works for you.

This works brilliantly!

I use this in my game:

local xForce = -math.sin( math.rad( 180 + player.rotation )) \* player.speed local yForce = math.cos( math.rad( 180 + player.rotation )) \* player.speed player:setLinearVelocity( xForce, yForce )

See if that works for you.

This works brilliantly!

I just wanted to drop you a note to say thank you… I’ve been looking for this piece of code for days.

I just wanted to drop you a note to say thank you… I’ve been looking for this piece of code for days.