Game Development Community

Complex mouse click offset bug...

by Jack Stone · in Torque 3D Professional · 02/07/2014 (8:50 pm) · 2 replies

Hello all,

This one is going to be a bit complicated to follow, but I'll try to explain as best as I can.

I have implemented a RTS-Type point and click interface in my game. Users can use the mouse to select objects on the battle field, as well as click icons on the on-screen gui. Right clicking and holding the right mouse button allows the user to pan and tilt the camera in 3d.
This all works perfectly except for one problem.

When the user right clicks and holds the button, and then moves the mouse (also moving the camera) the position of the "clicks" are offset from the visible location of the cursor.
So, for example, I right click and drag the camera, say, five units to the right. From now on every time I click the mouse the clicks are registering five units offset from the mouse cursor.

If I activate the console window, then hide it, then use canvas.cursoron() again, the position of the mouse has been reset, and will work fine until I next click and drag the camera.

I'm not sure how to go about debugging this. I have tried various canvas.cursoroff() and canvas.cursoron() calls, activating/deactivatng direct input, etc, but to no avail.

Is there some way to "reset" the mouse position to realign the visible mouse cursor to the actual "click" coordinates?

I would be hesitant to call this a T3D bug at this stage, it probably has something to do with the changes I made to implement object selection using the mouse cursor (This seems to also be affected by the offset).


Thanks for any advice!

#1
02/09/2014 (11:23 am)
That's a interesting one. Hard to actually pin down any code related problems without any provided code but to me it kind of sounds like you've got a little addition totalizer operation going on in there someone that's storing the prior offsets and then adding them as you go along.
#2
02/09/2014 (4:01 pm)
Thanks for your reply Robert. I actually figured this out. It was much simpler than I thought.
I had a command to add my game menu to the playgui inside my selection code for some reason, so I was calling:
"playgui.add(contextmenugui);"
Every time I selected something, and that was somehow messing with the position of the mouse. I didn't need that call in there, so removing it fixed the issue.