- Home /
Question by
indie6 · Apr 03, 2014 at 06:49 AM ·
movementaimmouse look
input mouseposition jitter
I am using Input.mousePosition to move the AIM on the screen. While moving I feel some kind of jittery movement, is there a way to fix that? Here is my code
void Update(){
//Aim is the cursor
Aim.transform.position = Input.mousePosition;
}
Is there a way to use deltaTime with mouse position?
Comment
Answer by FlyingHighUp · Apr 03, 2014 at 06:57 AM
Unsure what could be causing the jitter (unless something else is controlling the mouse) but if you wanted to smooth the inputted mouse position, you could go
public float Damping = 1f;
Aim.transform.position = Vector3.Lerp(Aim.transform.position,Input.mousePosition, Time.deltaTime*Damping);
Then increase/ decrease damping until the smoothing is your liking.
You can use Vector3.Lerp, because Input.mousePosition is a vector3, z is just set to 0.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141824im_/https://answers.unity.com/themes/thub/images/avi.jpg)