Basic Vehicle Functionality

Issue #121 wontfix
Former user created an issue

A basic prototype of one method of implementing vehicles, as discussed in the Cafu forums at [].

In this version, a player can walk up to a vehicle object, press the Use (Enter) key, and begin driving. The only implemented controls are to move forward (w), turn left/right (mouse left/right), and exit (space).

When a HumanPlayer is in a new "Driving" state, PlayerCommands received are passed on to the Vehicle instance to process. The Vehicle instance processes these commands on itself, then updates the HumanPlayer's position based on its current position to simulate the vehicle's POV.

Known issues: The vehicle is still rendered on the client system; occasionally it comes into view of the camera.

If the player is looking up or down when they enter the vehicle, they will be locked into that viewing angle while in the vehicle. (Vehicle does not normalize player's pitch.)

If the player is holding a weapon when they board the vehicle, the fpv model of the weapon will display while they drive.

Once in a while, seemingly just the first time it's attempted in a game, the player will just "freeze" instead of driving the vehicle. They can still exit the vehicle, after which everything seems to work normally (they can reenter it and behavior is normal), but no other commands seem to be processed. I've only noticed this since converting to r625, and it's difficult for me to reproduce.

The vehicle model should probably be something other than a floating Sentinel.

Comments (3)

  1. Carsten Fuchs

    Good work!

    I'll thoroughly review this code later, but at a first glance, this looks like a very good start for adding vehicles, but - as you wrote - it will also require some cleanup (just minor, not a problem, I'll do that when applying / integrating this code).

    Thank you very much for submitting this!

    (Does anyone have or know a suitable model for the vehicle? ;-) )

  2. Log in to comment