How to detect how much your physical mouse has moved?

What I am doing currently is basically if the user is holding a key then I can find the delta difference between the last frame and the current frame. This is basically mimicking picking up your physical mouse in real life and then moving it. My question is how do I just avoid this mess and figure out how much my physical mouse has moved?

Not too sure what you mean by that, but why don’t just check how much the cursor moved, instead of the physical mouse?

Because, then if I try and move my mouse up and put it back it will “reset” it

You can’t. The laser of the mouse won’t detect any more movement when the mouse is lifted up from a surface.

You don’t understand, that isnt what I am saying. When I put the mouse back down and try to move it the difference will cause it to mess up

I am still unsure what you mean, but you could code it so if the mouse detects really small movements, then it gets put back to last known position if that’s what you meant

Why does this sound like your mouse problem…

that is what I am doing! Here, maybe a video will help

I don’t quite understand you either but I think that you should use the position of the cursor like @Dyzody said.

Like I said, that is what I am doing. This is the code for it too

		local xoffset = deltaMouse.X - pastMouse.X
		local yoffset = deltaMouse.Y - pastMouse.Y
		yaw += math.deg(xoffset * 0.1)
		pitch += math.deg(yoffset * 0.1)
	pastMouse = deltaMouse

So, do you want to move the image with the mouse?

Ignore the image stuff, just imagine that yaw and pitch determines rotation of the camera

I think that is too hard for me. I’m not that advanced in scripting. sorry

1 Like

Fixed, use Enum.UserInputType.MouseMovement and MouseBehavior