Hello, i’m doing an Android pinball game and i have this code.
pe1 and p2 are the cubes used to hit the ball.
I think that the rotation is works good but I cant see any move i think because of the Touch use. Can anyone help me?
var toke : Touch;
var toke2 : Touch;
var pe1 : GameObject;
var pe2 : GameObject;
function Update () {
pe2.rigidbody.centerOfMass = Vector3 (0, 0, 2);
pe1.rigidbody.centerOfMass = Vector3 (0, 0, -2);
toke = Input.GetTouch(0);
toke2 = Input.GetTouch(1);
if ((toke.position.y > 200)(toke.phase == TouchPhase.Began))
{
if(pe1.transform.localEulerAngles.y < 45)
pe1.rigidbody.AddRelativeTorque(0,700,0);
else if (toke.phase == TouchPhase.Ended)
pe1.rigidbody.AddRelativeTorque(0,-700,0);
}
else if ((toke.position.y<=200)(toke.phase == TouchPhase.Began))
{
if(pe2.transform.localEulerAngles.y < 45)
pe2.rigidbody.AddRelativeTorque(0,700,0);
else if (toke.phase == TouchPhase.Ended)
pe2.rigidbody.AddRelativeTorque(0,-700,0);
}
if ((toke2.position.y > 200)(toke2.phase == TouchPhase.Began))
{
if(pe1.transform.localEulerAngles.y < 45)
pe1.rigidbody.AddRelativeTorque(0,700,0);
else if (toke.phase == TouchPhase.Ended)
pe1.rigidbody.AddRelativeTorque(0,-700,0);
}
else if ((toke2.position.y<=200)(toke2.phase == TouchPhase.Began))
{
if(pe2.transform.localEulerAngles.y < 45)
pe2.rigidbody.AddRelativeTorque(0,700,0);
else if (toke.phase == TouchPhase.Ended)
pe2.rigidbody.AddRelativeTorque(0,-700,0);
}
}