WASD camera control with mouse look

Home Forums Monkey 2 Code Library WASD camera control with mouse look

This topic contains 0 replies, has 1 voice, and was last updated by  Ethernaut 1 month ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #9910

    Ethernaut
    Participant

    Since last time I did something 2D in Mojo3D Mark yelled at me (just kidding! We love you Mark), here’s something more proper for 3D. After years (decades?) playing first person games, I really don’t like the “util.Fly” camera controls that’s in every Mojo3D example, so I made my own function that uses a control scheme more familiar to that sort of game.

    You can make a module out of it and it becomes really easy to Import and use. There’s one function you call at the start, and one that you call on every frame, with optional delta frame support (use delta = 1.0 for “normal” speed. I don’t like “millisecs based delta” ).

    If you use touchStyle = true, it seems more appropriate for touch screens, since you have to tap (click) then drag, and the camera pan&tilt follows the same direction of the drag. But I haven’t tested it on a touch based device, so feedback is welcome.

    Use example: in the Mojo3D examples, import this file and replace any line that says:
    util.Fly( _camera, Self )
    With:
    WasdCameraControl( _camera, Self, 1.0 )

    Default Keys:
    W,S – Move forward and back
    A,D – Strafe left and right
    R, F – Up and Down
    Shift – Move faster modifier
    Control – Move slower modifier
    Mouse to look around

    Still has some kinks, like losing track of the mouse if you switch to a different window and come back, or if you start the app with the mouse cursor outside the window. But it seems to work great if the app is fullscreen, so there you go:

    Cheers!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.