I have the following script attached to my camera:
var rotSpeed = 90.0;
var movSpeed = 10.0;
function Update () {
var x = Input.GetAxis(“Horizontal”) * Time.deltaTime * rotSpeed;
var y = Input.GetAxis(“Vertical”) * Time.deltaTime * movSpeed;
transform.Rotate(Vector3.up, x);
transform.Translate(0, 0, y);
}
The intention is to move the camera forward or back when W and S are pressed and to rotate the camera view when I press A or D. Now, this does in fact accomplish this task, but I am seeing the following issues:
- If I hold down either A or D continuously I should rotate completely around in a circle in 4 seconds (i.e. 90 degrees per second * 4 seconds = 360 degrees). However, this is not the case. In reality, I’m getting intermittent slowing and speeding up during the time I have the keys depressed. Really sluggish for the most part. The scene only consists of 2 cubes.
- The camera continues to move even after I’ve released the keys. There is a slow-down period where the camera slows down and finally stops instead of just stopping. I’m assuming this is some sort of keyboard buffering, but I don’t know why that would be the default behavior nor do I know how to stop it.
Furthermore, I tried this simple script and attached it to the cube in the scene:
function Update () {
transform.Rotate(Vector3.up, Time.deltaTime * 60.0);
}
The object doesn’t rotate at the same rate. It slows down and speeds up, seeming to be really sluggish at times. I can’t help but think I’m doing something fundamentally wrong.
My system specs are as follows:
Microsoft Windows XP with Service Pack 3
Intel Core 2 Duo 3.0GHz
3.25 GB RAM
ATI Radeon HD 2400 Pro
Catalyst Version 11.6