Adding vehicles
Posted: 2012-06-29, 01:34
So I've been trying to work out the best way to implement vehicles in this engine, and the most relevant thread I've been able to find - http://www.cafu.de/forum/viewtopic.php? ... &view=next - is from 2008, so I thought it better to start a new topic to ask for clarification rather than raise a zombie thread
The overall method that I've been looking at, largely based on what I understood in that thread, is to have the player switch to a new "piloting" state of existance when a vehicle is entered. Basically, when a vehicle is boarded, the HumanPlayer takes on the characterstics of the target vehicle (model, position & rotation, max speed, health, armor, bounding box & physics...), and the camera position changes to reflect the size of the player-vehicle. The vehicle entity is removed from the world, and the player replaces it, all (hopefully!) seamlessly. Player controls would then be processed by a new player state branch in Think(). When a player disembarks, all these changes are reversed, and the vehicle entity is dropped back where the player's current position is, and the player's position is adjusted to something reasonable.
My main concern is that this seems a bit overcomplicated and inflexible. Would it make more sense to have the piloting state indicate that all control updates (and camera POV) should be applied to the player's piloted vehicle entity, and that the actual HumanPlayer entity should be removed from the world? Can the camera and controls be decoupled this way? Or is there a better way I'm not seeing?
The overall method that I've been looking at, largely based on what I understood in that thread, is to have the player switch to a new "piloting" state of existance when a vehicle is entered. Basically, when a vehicle is boarded, the HumanPlayer takes on the characterstics of the target vehicle (model, position & rotation, max speed, health, armor, bounding box & physics...), and the camera position changes to reflect the size of the player-vehicle. The vehicle entity is removed from the world, and the player replaces it, all (hopefully!) seamlessly. Player controls would then be processed by a new player state branch in Think(). When a player disembarks, all these changes are reversed, and the vehicle entity is dropped back where the player's current position is, and the player's position is adjusted to something reasonable.
My main concern is that this seems a bit overcomplicated and inflexible. Would it make more sense to have the piloting state indicate that all control updates (and camera POV) should be applied to the player's piloted vehicle entity, and that the actual HumanPlayer entity should be removed from the world? Can the camera and controls be decoupled this way? Or is there a better way I'm not seeing?