- Home /
Question by
konashadow · Jun 02, 2013 at 04:58 AM ·
camerarotation
Rotation of Camera Slowing Down and Stopping?
Hello everyone, My current problem is that I want the camera of my game to be able to turn 360 degrees, but with my current code, as it reaches 180 degrees from both the right and left side, it slows down and stop rotating altogether. Here is the code.
#pragma strict
function Update () {
if(Input.GetKey(KeyCode.D))
{
transform.position += transform.right *5 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.A))
{
transform.position -= transform.right *5 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.W))
{
transform.position += transform.forward *5 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.S))
{
transform.position -= transform.forward *5 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.R))
{
transform.position += transform.up *5 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.F))
{
if(transform.position.y >= 1)
{
transform.position -= transform.up *5 *Time.deltaTime;
}
}
if(Input.GetKey(KeyCode.E))
{
transform.rotation.y += 2 *Time.deltaTime;
}
if(Input.GetKey(KeyCode.Q))
{
transform.rotation.y -= 2 *Time.deltaTime;
}
}
Thanks in advance
Comment
Best Answer
Answer by Tomer-Barkan · Jun 02, 2013 at 06:06 AM
use this instead:
if(Input.GetKey(KeyCode.E))
{
transform.Rotate(0, Time.deltaTime * 2, 0);
}
if(Input.GetKey(KeyCode.Q))
{
transform.Rotate(0, -Time.deltaTime * 2, 0);
}