Clean Rotation issue! Need rotation legend to help :)

I am trying to move an object in a particular direction based on the angle it’s aimed in with a script like this-

LocalVelocity = (transform.InverseTransformDirection (rigidbody.velocity));//Get the current local velocity
rigidbody.AddRelativeForce (Vector3(-(LocalVelocity.x),0,0), ForceMode.VelocityChange);// ad a negative x local velocity to keep moving in the direction it's aimed

This works great and the object will go in the direction it’s pointed in, but…

Part of my game mechanic requires me to be able to rotate the object around on the y axis(to aim), but since you can never actually apply a clean y euler rotation on a rigid body I’m not sure how to get the aiming part to work right.

I thought that maybe I could have an object that sits on top of the rigidbody gameobject (in the hierarchy) but I couldn’t run transform.InverseTransformDirection on that as there is no rigidbody.velocity to base it’s direction on.

Does anyone have any ideas on how I could do this? I’ve been banging my head against a wall for weeks on this now, I really didn’t think it would be this hard.

Pete.

Although I don’t fully understand what you’re asking, it sounds like you might want a rigid body with ‘freeze rotation’ on (a particle, essentially) with another object as a child of that object that handles the rotation.

If that’s not the solution you’re looking for, perhaps you could elaborate on the question a bit.

Thanks Jesse,
Sorry it’s a hard one to explain! But I seem to have it working now by using Mathf.LerpAngle. I never new that existed but it seems to work great!