I want to make it so that a pilot, can control the pitch and roll of a craft using mouse. Vertical axis would be the pitch, horizontal axis would be the roll, like in most other games with aircraft (ie Battlefield 2).
I don't think linking the craft's angle to the player's view angle would be a good idea, because I want a maximum rate at which the craft can turn. So ideally, moving the mouse would just apply thrust in that direction.
So more directly, my question is: How do I detect that the mouse is moving upwards, or sideways?
Has anyone ever made an aircraft controlled with the mouse? All I'm asking is how to read which direction the person is moving their mouse.
[b][url=http://wiki.garrysmod.com/?title=Gui.MousePos]Gui.MousePos [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[b][url=http://wiki.garrysmod.com/?title=Gui.ScreenToVector]Gui.ScreenToVector [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[editline]17th May 2011[/editline]
Gives a direction.
I'm sorry but this has a few issues.
First of all, the MousePos is always 0,0 unless you enabled cursor. Even if you have enabled cursor, which is undesirable in this case, the cursor would eventually move to the top of the screen and you wouldn't be able to continue increasing your pitch.
My idea that I'm going to work on is using EyeAngles, and resetting the EyeAngles regularly to make sure the player doesn't look all the way up. Basically compute the horizontal and vertical change in the EyeAngle. I'm overriding CalcView anyways, so the player won't notice.
Player.GetAimVector
Yes Player.GetAimVector seems to do the same thing as Player:GetEyeTrace().Normal. However you have to reset it regularly, otherwise the player's aim will get to the top of the screen, preventing farther vertical movement.
To clarify, I want the controls to function like a normal flight simulator. Upwards movement generates downwards pitch change (or upwards if you like to fly inverted).
You could scale the movement, when the cursor is at the top/bottom/left/right it is at maximum velocity/thrust/whatever on those axis' .
[QUOTE=Fantym420;29881658]You could scale the movement, when the cursor is at the top/bottom/left/right it is at maximum velocity/thrust/whatever on those axis' .[/QUOTE]
I considered this, but this not optimal. In a normal flight sim, you apply thrust in a direction by MOVING the mouse. When the mouse is not moving, your pitch and roll are not affected. With the the sort of controls you are suggesting, it would be somewhat difficult to stop rolling or pitching, and it would be somewhat awkward to control.
[QUOTE=infinitywrai;29895068]I considered this, but this not optimal. In a normal flight sim, you apply thrust in a direction by MOVING the mouse. When the mouse is not moving, your pitch and roll are not affected. With the the sort of controls you are suggesting, it would be somewhat difficult to stop rolling or pitching, and it would be somewhat awkward to control.[/QUOTE]
If you make the mouse return at a set rate to center or just snap back then it would stop thrusting at the rate you specify, kinda like the centering spring in a joy stick, but it's up to you I was just throwing out ideas. Good luck.:smile:
Sorry, you need to Log In to post a reply to this thread.