- Home /
Ball Rotating Help
I had a problem in this script. When i press Input.GetAxis("Vertical"), it will accelerate the ball, but it still accelerating without stopping. The camera also gone crazy when the ball goes fast (i use unity built in SmoothFollow.js).
can anyone help me ?
this is my ball script :
var speed = 10.0;
function FixedUpdate () {
if(Input.GetAxis("Horizontal")){
var horizontal = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
}
if(Input.GetAxis("Vertical")){
var vertical = Input.GetAxis("Vertical") * speed * Time.deltaTime;
}
var force = Vector3(horizontal,0,vertical);
if (rigidbody.velocity.magnitude < speed * Time.deltaTime) rigidbody.AddForce (Vector3(horizontal, 0, vertical), ForceMode.Acceleration);
Debug.Log(force);
}
Comment