transform.Rotate giving me odd results

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:

  1. 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.
  2. 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

As far as 2) goes, change the settings for the appropriate axis in the input manager. As far as 1) goes, I would have to assume that you have some other script also acting on the object.

–Eric

I’m able to narrow this down now. It appears that this happens consistently within the World Editor when I hit the Play button and on any setting better than Simple from a built executable. So it seems that my script logic is fine, but that the issue is with Unity3D when running in the editor or in an EXE with Good or better quality. I would think my Core Duo 3GHz machine with Radeon HD 2400 card could do better with a scene containing only 2 cubes. It seems to work fine on much more complex demos.

Any ideas?

Unfortunately no, I haven’t heard of anything like that, sorry.

–Eric

Issue #2 can be solved with the Input Manager settings as you suggest. I also removed all scripts from the project except one for the Camera movement and one for the cube rotating. And although the Stats show it running at over 2500 FPS, the cube is sometimes sluggish and sometimes smooth. And moving the camera is the same way. But in the EXE in simple mode, it works fine.

OK, so I’ve discovered that this works fine in full screen mode even on Fantastic quality setting. It only appears to happen in Windowed mode EXE or in the editor (which is also windowed mode of course).

If I were you I’d just use this script and modify it so that the W&S are used to move the camera back and forth.