   How to implement sitting in cars, planes, ships?
  I'm writing a game and want to implement something like GTA, Mafia, where you can walk in the city, but then you can jump in the car and drive...So the task is: I have a person, I have a car. How (in program manner) they interact on "enter", when driving, when leaving? Do the car have a list of people inside, or every person has a parent object (what to drive)?   
  Seems like there's no one can create something more difficult than tetris.   ;  I'd venture to guess that you want the vehicle to be an interactable object.It probes for characters to interact with it, then upon interaction, decides what to do.The what to do part would involve taking hold of the player/character setting both the car and player into their "enter car" animations.From there, you'd decide who is in control (player gets control, or the character says I wanna go here! and the car then drives along the streets that it knows)Then to exit, the car would again put both characters in their exit animations, and release control of the player.Or, depending on your system, you could set it up so that the player just has a pointer to the vehicle it is controlling at any one time, and then wrap the human model of the player as just another vehicle to simplify code.Then you would only have to write one interface to interact with, but it could be more limiting as far as what can be different about each vehicle.Where as having the objects take control of the game when you interact with them give you more flexibility as far as adding new features when interacting with an object.(less likely that the people on the boards only know how to make tetris, and more likely that you are VERY vague, and much of the "how does it interact" revolves around what you already have working and what other features you might want, as the range of features can dictate what is the easiest way to go about solving the problems.);Quote:So the task is: I have a person, I have a car. How (in program manner) they interact on "enter", when driving, when leaving? Do the car have a list of people inside, or every person has a parent object (what to drive)?Your post is too broad, which might explain why some people don't bother responding.Most likely, the vehicle itself is an object that contains variables (seats) for occupants (people).  The vehicle would provide an interface that the occupant located specifically in the driver's seat would use to control the vehicle.  At this point - assuming that the driver of the vehicle is the player - then the input from the player would control the vehicle (i.e. pressing "Left" no longer moves your character to the left, but turns the wheels of the vehicle to the left).As for entering the vehicle, the matter is probably one of proximity.  If the player's character is close enough to a vehicle, then a certain key-press would automatically insert the character into the vehicle, and now player input would control the vehicle.  When the player wants to exit the vehicle, they simply press an assigned key, whereupon the character is automatically removed from the vehicle and player input returns focus on the character.Hopefully that provides some insight into what you're interested in.  If you want to see the details of the code, you'll probably have to supply the code that is giving you a hard time.   ;  A vehicle has a fixed number of seats.  Therefore you should use a fixed size array for occupants.Vehicles should have a method to see if there's anyone already in the vehicle that you need to kick out before you can get in.You need "tandem animation" support (ability to animate two objects to make them look like they're interacting with each other).Vehicles should have one or more interaction zones (probably just a radius and center that is parented to the vehicle), but the player update should look for the interaction zone instead of the vehicle looking for the player.  Remember, there will be few players and many vehicles.For the rest, you should identify the common interfaces and behaviors that a person and vehicle share (rendering, input handling, camera control, etc) to determine how your code should be architected.If you want to do something more advanced like the Battlefield does with its vehicles, you should consider object-orienting each SEAT in a vehicle in addition to the vehicle itself.You should also sketch out a flowchart (aka: state machine) of how you want your players to interact with vehicles.  If you can make a well designed flowchart, you can directly implement it in code.   