FlashX
1
Hey guys,
Im having some difficulty getting my character to stay still when my gamepad is in a ‘resting’ pose. Currently if i let go of the joystick, my character doest stay in the last facing direction and slowly glides across the floor, any ideas as to how to fix this? im sure its something simple.
void Update ()
{
float moveHorizontal = Input.GetAxisRaw ("Horizontal");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, 0);
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(movement), 0.15F);
}
I guess this happens because your joystick isn’t resetting to exact middle and deadzone is what you need to edit a little to fix this problem.
- Go to Edit > Project Settings > Input
- Edit value of “Dead” to be higher.
On other note of your code is that you should multiply your movement by Time.deltaTime and probably create new float speed and use that as multiplier too to control how fast movement will be. Currently your movement speed is defined by framerate making your character move faster on higher framerates.