My character has a car, that he will use to get around the open world in my game. I am trying to write a script that will monitor to see if the player presses the E key if they are within, say, 10 units of the car. If the two parameters are met, the player prefab will be deleted, and the player will be put in control of the car (as if the player got into it).
I have tried var distance = Vector3.Distance(object1.transform.position, object2.transform.position); , but that does not work.
Can point me in the right direction to get started?
-Thanks
Vector3.Distance does work, and is what you would use.