Hi! I wanted to ask how to reset roation of object?

I am using mouselook actuator to rotate my gun with mouse(aim), but I want it to set back to default position after releasing right button(used to aim). How to do it?

Object.worldOrientation = an object facing the right way.worldOrientation.

Like parent a empty to the actor, that faces,the right way ,

If mouse click inverted object.worldOrientation = empty.worldOrientation

Or, insert a orientation keyframe that is faci,g the right way

If mouse click invert = and = play action your keyframe action

The second method almost owrked, but I couldn’t find the final resolvement. I can’t understand the first method clearily!


This assumes the turret’s pointing along the positive Y axis, and your un-clicked orientation goal is 0,0,0 rotation.
The first alignAxisToVect aligns the turret back to the Y axis. The last arguement ‘0.5’ is the speed at which the object will move to reach its goal.
The second alignAxisToVect just keeps the turret’s Z axis pointing upward.

I think alignAxisToVect() has become one of my favorite new toys :smiley:

Record an animation keyframe with the gun axis aligned (facing forward).
Parent the gun to an empty which is aligned to the rest alignment. This is required, so that the animation works even when the player turns.
When you want to reset the orientation, play the keyframe. Because it is parented to the empty, the gun will not rotate to the world Y axis, but the empty y axis. I assume this empty would be parented to the player.

Thanks goose,

I probably should have explained that better,