Jump to content

[solved - no bug]screen center off?


Recommended Posts

Hello,

 

as other have already noticed and what i tried to solve in my Lua script is that the camera moves slowly up or down when not moving the mouse.

 

For me the camera in Aggrors Tutorial code is slowly moving up:

http://www.leadwerks.com/werkspace/page/tutorials/_/making-a-third-person-camera-r16

 

i added a small difference in code to solve this for me in the entity script:

http://www.leadwerks.com/werkspace/files/file/436-fps-and-tps-controller/

 

however other then seems to have the issue that it slowly moves down.

 

So i think that this must be a difference that is different for every one.

 

 

I am not exactly sure why this happens but maybe window borders are included somewhere?

Link to comment
Share on other sites

Aggror and I saw this in his script for lcp. We put in the following to prevent it:

 

mouseDifference.x = currentMousePos.x - centerMouse.x

if (math.abs(mouseDifference.x)) > 0.1 then
local tempX = camRotation.x + (mouseDifference.y / mouseSensitivity)
if tempX > cameraTopAngle and tempX < cameraBottomAngle then
camRotation.x = tempX
end
camRotation.y = camRotation.y + (mouseDifference.x / mouseSensitivity)
camera:SetRotation(camRotation)
end

 

We were seeing that mouseDifference.x was a very small number even when not moving. We were expecting 0 but it wasn't. At that point the amount if moves depends on the persons FPS because it's just in UpdateWorld() which I'm pretty sure just runs as fast as possible. The higher the FPS the more noticeable the movement.

 

I think this may be a Lua issue or something. I haven't tested but I noticed you guys take the screen width/height and divide by 2. I always just pick a value like 100 for both and use that to avoid the division and any possible side effects that might come with that (this possibly being one of them). The reset position of the mouse doesn't have to be the screen center. It just has to be consistent.

 

I can do more testing on this but this fix worked so I just forgot about it.

Link to comment
Share on other sites

Thanks for the help.

 

I think i am just stupid.

 

I tested with vsync enabled/disabled (needed to disable that as well in the driver settings)

 

and the difference was always -0.5

 

 

Then it hit me.

The mouse can of course not be set to half pixels. :)

 

So i only need to set the mouse to full pixels.

 

So just rounding the center position of the context should help:

self.centerMouse = Vec2(math.floor(context:GetWidth()/2), math.floor(context:GetHeight()/2) )

 

No need to look if the difference is higher than 0.1 or anything like that.

Link to comment
Share on other sites

No need to use the center screen even. Just pick like (100, 100) or something like that smile.png All you're looking for in this case is the change in mouse position from a given location anyway.

 

You'll never have a resolution lower then 100 so you'll always have a 100,100 location and it greatly simplifies the situation. Especially for newbies trying to understand the code.

Link to comment
Share on other sites

i think it is better to use the center of the screen.

 

i have my mouse set to a very high sensitivity and if i move my mouse quick enough it is no problem sometimes to escape the window of some games that are supposed to capture the mouse. If i click then i lose focus of the window.

 

this issue is also depending on the framerate my pc can render.

 

 

If i just set it into the center i minimize the possibility as much as possible to all sides.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...