Look around using mouse like in most PC FPS games
BlitzMax Forums/MiniB3D Module/Look around using mouse like in most PC FPS games
| ||
Gfx provided me with some very helpful MouseXSpeed and MouseYSpeed substitutes, but I cannot figure out why the following code refuses to budge the camera when I move the mouse:TurnEntity camera,-mouse.YSpeed()*0.9,mouse.XSpeed()*0.9,mouse.XSpeed()/10.000 Could I please get some help? |
| ||
Just a guess, but try: TurnEntity camera,-Float(mouse.YSpeed())*0.9,Float(mouse.XSpeed())*0.9,Float(mouse.XSpeed())/10.000 |
| ||
No, that's not the issue. For some reason, when I'm calling the function for drawing text, everything goes smoothly ( text 50,50,"MouseYSpeed: "+mouse.YSpeed();text 50,60,"MouseXSpeed: "+mouse.XSpeed() ) but when I assign it to a variable or do anything other than text for that matter, it usually returns 0 but occasionaly returns *something* just to throw me off. Main program (revised to use RotateEntity rather than TurnEntity because TurnEntity doesn't seem to support roll whereas RotateEntity does) TMouse.bmx (thanks to Gfx): Global mouse:tMouse = New tMouse Type tMouse Field lastX:Int Field lastY:Int Method XSpeed:Int() Return MouseX() - lastX End Method Method YSpeed:Int() Return MouseY() - lastY End Method Method update() lastx = MouseX() lasty = MouseY() End Method End Type And TPlayer.bmx: |
| ||
I'd probably encapsulate the mouselook capability within the mouse class itself, to make things a little tidier. Your code structure is somewhat unkind to my way of thinking, so I can't help you directly, but here's a simple example that hopefully will help: |
| ||
Your code was a bit.. jumpy.. for me, but this code works wonderfully: Can't remeber where I found it XD I thought I copied your code but apparently this remained on the clipboard. Thanks all for the help. |
| ||
I have unfortunately learned that making mouse move code that works well on a lot of different computers is tough in OpenGL. The results with the various drivers are pretty inconsistent. At least, that has been my experience. :( |
| ||
I have unfortunately learned that making mouse move code that works well on a lot of different computers is tough in OpenGL. I have also noticed this. I've yet to find an acceptable solution in Mac OS 10.5. It is annoying the hell out of me... |
| ||
Here's a partial framework that functions reasonably well on MacOS 10.5, but still isn't entirely smooth: EDIT: Removed code. Works crap on Windows... Back to the drawing board... |