# problem with changing direction of relative force

Hello every one
I have problem with my code and when I change the direction of my object the relative force don’t change properly and my object get out of control.
I need to know how can I change my force direction smoothly and quickly?
I write this code in Update and next in Fixed update and test it with AddForce and AddRelativeForce but in none of them I can’t find my answer.

``````	var UpForce : float;
var MaxSpeed : float = 100;
var MinSpeed : float;
var Speed : float = 1;
var Acceleration : float = 100;
function Update () {
UpForce = rigidbody.velocity.z/10;
UpForce = Mathf.Clamp(UpForce,0,7);
rigidbody.AddForce(0,UpForce,0);
// speed control
Speed = Mathf.Clamp(Speed,MinSpeed,MaxSpeed);
if(Speed <= MinSpeed){
Speed = MinSpeed;
}
if(Speed >= MaxSpeed){
Speed = MaxSpeed;
}
if(Input.GetKey(KeyCode.B)){
Speed = Speed + 1;
}
if(Input.GetKey(KeyCode.N)){
Speed = Speed - 1;
}
if(Input.GetKey(KeyCode.A)){
transform.Rotate(0,0,Acceleration*Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)){
transform.Rotate(0,0,-Acceleration*Time.deltaTime);
}
if(Input.GetKey(KeyCode.S)){
transform.Rotate(-Acceleration*Time.deltaTime,0,0);
}
if(Input.GetKey(KeyCode.W)){
transform.Rotate(Acceleration*Time.deltaTime,0,0);
}
Debug.Log("force:" &&  rigidbody.AddRelativeForce.z);
}
function FixedUpdate(){
rigidbody.AddRelativeForce(0,0,Speed);
}
``````

I think the Unity3d have bug in this case or it’s very very hard to control this force and I use the rigidbody.velocity for my script and every thing solved.
but the realism of my game get very low.