Why do so many people scale mouse motion Input with delta?

Godot Version

4.5.stable

Question

Hey, I am pretty new to godot and semi new to actually trying to program something more complex. I was not sure if this category is the best fir for the question but I feel like the other ones would have been a worse fit.

I am currently setting up a simple PlayerController again and was looking at other peoples examples to get a feel for a way to make it feel smooth and nice to use. Looking at other peoples examples I noticed some(plenty) use delta time to “scale” their mouse input. I understand that it is often used for movements to make them frame independent, but I feel like in this case it should hinder the input consistency of the mouse?

I am looking at a script like this:

func _unhandled_input(event: InputEvent) -> void>
	if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAMPTURED:
	_camera_input_motion = event.screen_relative * sensitivity

func _physics_process(delta: float) -> void:
	_camera_pivot.rotation.x += _camera_input_motion.y * delta

My thought being that if we “scale” our mouse movement with delta here we would essentially just change the amount of camera rotation we do with the same Input depending on our current fps.
Meaning by getting rid of the delta scaling we should have a controller that always rotates the camera by the same amount if the mouse Input is the same, in contrast to the camera rotating less if we suddenly have higher fps.
So my idea would be to use this:

func _unhandled_input(event: InputEvent) -> void>
	if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAMPTURED:
	_camera_pivot.rotation.x += event.screen_relative * sensitivity

Am I looking at this the wrong way?

You’re right. Scaling mouse input with delta makes no sense. It treat relative mouse movement as velocity, which is a bit strange.

I think it wants the rotation to be constant with the same mouse motion and
over the same period of time.

For that, it requires a time component. ( delta:float )

I thought that by multiplying by delta, it would increase the movement when frames are lower, so that when you have low frames and object would still move the same amount of distance instead of moving slower if you have low fps or faster if you have high fps?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.