- Home /
Question by
rogiedodgie · May 21, 2015 at 06:21 AM ·
rigidbody
Rigidbody2d won't move in Newest Unity
I have created a rigidbody 2d in Unity 5.0.1f1. I then added a box collider 2d.
I attached the following script to the box:
pragma strict var Xforce : float; var Yforce : float; var temp : float;
function Start () {
}
function Update () { Xforce = 20f; Yforce = 20f; temp = Input.GetAxis("Horizontal");
var rb = GetComponent.<Rigidbody2D>();
rb.AddForce(new Vector2 (Xforce * temp,0));
}
However, when i press left and right, the value of temp scales from -1 to 1, but the object doesn't move.
Any ideas how to fix this!
Driving me crazy!
Roger
Comment
Your answer