I’m creating a multiplayer shooter in which you have the ability to enter a car.
This is what I do:
-> linetrace in front of player and check if it hits the car.
-> cast to the car and set the car’s actor class variable (which is replicated) to self
-> possess the car
if I want to leave the car I just place the player (which I saved in the car’s actor class variable) next to my car.
but I’m getting errors when I try this if the player is in the car for more than 5 seconds. The actor doesn’t seem valid anylonger.
You destroy character when you enter to car? If yes then actor cant be valid i think… you have problem with respawning player next to car? If yes then store somewhere changed variables and when you spawn that actor, override that variables imo. I think saving reference and using that reference for spawning pawn is not possible but im not sure.