- Home /
How to roll a Jet (GameObject with a RigidBody)
So I want to rotate it smoothly around the x-axis. When the X-velocity is positive, I want the rotation to be zero, and when it is negative, 180 degrees. I got this far below, but I'm not sure how to finish it.
public var rotationSpeed:float = 5;
public var targetAngle:float = 0;
public var mod:Transform;
function Update () {
var rig:Rigidbody = this.rigidbody;
if(rig.velocity.x > 0){
targetAngle = 0;
}else{
targetAngle = 180;
}
Comment
Answer by Berenger · Jun 22, 2012 at 02:21 AM
That's seems alright. Except that assigning the value of rigidbody into a var is useless here as you use it only once, but it's not a big deal.
You need to apply targetAngle on transform.Rotation now.