Question by
JohnnyMccrum · Aug 11, 2018 at 01:48 PM ·
cameramovement script
WSAD movement seems "floaty" and delayed.
Hello, I have the following move method, which works and is fine for my purposes, but the movement feels very "floaty" and delayed...almost laggy.
Specifically, in the "WSAD movement" section of the code.
I'm not sure what might be causing the lag, or if this is the best way to design my movement system.
How could I resolve this?
private void MoveCamera()
{
float xpos = Input.mousePosition.x;
float ypos = Input.mousePosition.y;
Vector3 movement = new Vector3(0, 0, 0);
//horizontal camera movement
if (xpos >= 0 && xpos < ResourceManager.ScrollWidth)
{
movement.x -= ResourceManager.ScrollSpeed * Time.deltaTime;
}
else if (xpos <= Screen.width && xpos > Screen.width - ResourceManager.ScrollWidth)
{
movement.x += ResourceManager.ScrollSpeed * Time.deltaTime;
}
//vertical camera movement
if (ypos >= 0 && ypos < ResourceManager.ScrollWidth)
{
movement.z -= ResourceManager.ScrollSpeed * Time.deltaTime;
}
else if (ypos <= Screen.height && ypos > Screen.height - ResourceManager.ScrollWidth)
{
movement.z += ResourceManager.ScrollSpeed * Time.deltaTime;
}
//WSAD MOVEMENT
//horizontal camera movement
if (Input.GetAxis("Horizontal") < 0)
{
movement.x -= ResourceManager.ScrollSpeed * Time.deltaTime;
}
else if (Input.GetAxis("Horizontal") > 0)
{
movement.x += ResourceManager.ScrollSpeed * Time.deltaTime;
}
//vertical camera movement
if (Input.GetAxis("Vertical") < 0)
{
movement.z -= ResourceManager.ScrollSpeed * Time.deltaTime;
}
else if (Input.GetAxis("Vertical") > 0)
{
movement.z += ResourceManager.ScrollSpeed * Time.deltaTime;
}
Comment
Hi @Johnny$$anonymous$$ccrum - I confess I didn't read the code, but I saw you are using Input.GetAxis - it has built in transition time to fully pressed, so the values never go instantly from zero to one. Not sure if your problem is related to that, but you can also use GetAxisRaw, which gives you the raw keypress values.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172619im_/https://answers.unity.com/themes/thub/images/avi.jpg)