- Home /
Question by
tommy93 · Sep 06, 2014 at 10:30 PM ·
rotationrotaterigidbody2drotate object
Rigidbody rotation problem
Cua are new in UNITY. I wanted to make a script that would allow me to turn around to 'z-axis a ball in 2d and that simultaneously traslasse along the' x-axis. In practice, the final result must be a ball that rotates and translates as when you make a pass with the soccer ball. I write this code
#pragma strict
var speed : float;
var ball : Rigidbody2D;
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
ball.transform.Translate(Vector3(speed, 0, 0));
}
}
}
I hope someone suggests the system to rotate the ball. Thanks
Comment