Hi! I have a character and a vehicle. When I parent a character to a vehicle I want a character to copy the facing direction of a vehicle and the position.

Green arrow represents a vehicle and a blue one is a character when entering a vehicle from the side, then inside a vehicle. Character should face the direction of a vehicle. Then when exiting a vehicle a character should too copy the direction with and offset respresented by red dotted line.
My wrong code is something like this:
# Entering a vehilce
get_parent().remove_child(self)
vehicle.add_child(self)
global_transform.origin = vehicle.transform.origin + Vector3(0.5, 1.75, 0)
shape.rotation.y = vehicle.transform.basis.get_euler().y
# Exiting a vehilce
get_parent().remove_child(self)
main_scene.add_child(self)
global_transform.origin = vehicle.transform.origin + Vector3(2, 1, 0)
I'm very bad at this, sorry.