Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

AddForce on GetAxis always sam direction?

$
0
0
I am creating my own roll-a-ball script, and if the player touches the up, down, left, or right key the ball will roll in that direction. The problem is that if I press the left or right key, it will always go in the same direction. Same with the up and down keys. Here is my code: var player : Transform; function Start () { } function Update () { if(Input.GetAxis("Horizontal")) { player.rigidbody.AddForce (5, 0, 0); } if(Input.GetAxis("Vertical")) { player.rigidbody.AddForce (0, 0, 5); } } Does anyone know what I am doing wrong?

Viewing all articles
Browse latest Browse all 1264

Trending Articles