Character goes inside vehicle but cant do nothing else. Cant exit and cant drive.
You can only have a single controller class. This requires your vehicle controls to be implemented in the Controller, or in the Vehicle itself. If in vehicle, then your characters controls must be in the character class.
If all is in the Controller, use On Event Possess in the controller to determine Character or Vehicle. Any easy way to determine is adding an actor tag and checking against it, Then Cast.
Possession/UnPossess takes place in the Gamemode.
Enter event is executed on Server. Pawns authrpoxy calls event in GM to unpossess Pawn, and possess Vehicle.
Exit is the same process.
Ok thanks. Now i can enter\exit the car and drive but when exit i cant move the character anymore
Did you possess the character?
Mapping contexts are set that vehicle is in the upper one and player in the remove one. I dont fully understand these yet
Mapping Contexts are setup on Begin Play in both the Character and Vehicle classes.
All Controls are coded/scripted in their respective classes.
e.g. controls IN the Character class… same applies to the vehicle class.
Entering the vehicle uses a line trace for interaction. Client traces and gets a hit, it then RPC’s server to Trace. If the server hits the vehicles interaction collision it executes an event on the Game Mode. We pass a reference of the character and the vehicle to the event.
Exiting the vehicle is simple input process to call an event on the game mode. First we call an event on the vehicles “Auth Proxy”, in which calls the GM event.
Game Mode Enter/Exit events
Each of these events has a dedicated function to process the logic.
Entering the vehicle…
Note that the vehicle has a “reference variable” for the character that we set. This is so we can retrieve the character on exit.
Exiting the vehicle…
Majority of the functions code is determine the teleport to location for the character. Important part is as follows.
Thanks now it works