system
1
Hey guys,
i'm trying to make a game where you fly in a little air plane,
so i made a script to steer it.
But now, it won't rotate more than 180 degrees.
i.e. when i press the left button, it will rotate to the left but it stops at 180 degrees.
Here's a copy of the script:
var moveSpeed = 1.0;
var turnSpeed = 1.0;
function Update()
{
transform.position += transform.forward * moveSpeed * Time.deltaTime;
if(Input.GetButton("Forward"))
{
transform.rotation.x += turnSpeed * Time.deltaTime;
}
if(Input.GetButton("Backward"))
{
transform.rotation.x += -turnSpeed * Time.deltaTime;
}
if(Input.GetButton("Left"))
{
transform.rotation.y += -turnSpeed * Time.deltaTime;
}
if(Input.GetButton("Right"))
{
transform.rotation.y += turnSpeed * Time.deltaTime;
}
}
Thanks!
system
2
Use Transform.Rotate instead of directly setting the rotation.