Jump to content

FPS Controler Floating mouse look


Recommended Posts

Thank you for reporting this.  Although I cannot produce the problem, I made a change that might fix it for you.  Please try the latest update and tell me if it helps.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Mine is windows 10, and this is my display setting

I switched Scale to 100% and everything is ok now, but this still need to be fixed for other scale option of windows :"D

with 100% scale, every text on my screen is so small, I can't switch between 100 and 125% every time I wanna test my game hehe

2017-06-19 14_27_59-Settings.png

Link to comment
Share on other sites

The problem is that ClientToScreen and ScreenToClient don't match at that scaling factor. 

	void Window::SetMousePosition(const float x, const float y)
	{
		POINT point;
		point.x = Math::Round(x);
		point.y = Math::Round(y);
		ClientToScreen(hwnd, &point);
		SetPhysicalCursorPos(point.x, point.y);
		
		//Test
		POINT testpoint = point;
		ScreenToClient(hwnd, &testpoint);
		Debug::Assert(testpoint.x == point.x);
		Debug::Assert(testpoint.y == point.y);
	}

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

There is a way around this if we modify our FPS Player script.  First we get the mouse coordinate immediately after it is set:

	--Mouse look
	self.currentMousePos = window:GetMousePosition()
	window:SetMousePosition(Math:Round(context:GetWidth()/2), Math:Round(context:GetHeight()/2))
	local centerpos = window:GetMousePosition()
	self.currentMousePos.x = Math:Round(self.currentMousePos.x)
	self.currentMousePos.y = Math:Round(self.currentMousePos.y)

And then we compare the current position to that instead of the context center:

	self.mouseDifference.x = Math:Curve(self.currentMousePos.x - centerpos.x,self.mouseDifference.x,2/Time:GetSpeed())
	self.mouseDifference.y = Math:Curve(self.currentMousePos.y - centerpos.y,self.mouseDifference.y,2/Time:GetSpeed())
	self.camRotation.x = Math:Clamp(self.camRotation.x + self.mouseDifference.y / self.mouseSensitivity,-90,90)
	self.camRotation.y = self.camRotation.y + (self.mouseDifference.x / self.mouseSensitivity)

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...