- Home /
Enter Car On KeyDown
I'm trying to make a FPS and I have a car that I would like to enter when a key is pressed. I've set up the trigger I just don't know how to actually move the player to sit inside the car? If you could give me the script that would be great or just a rough idea on how to do it. THANKS IN ADVANCE!
EDIT -> I can move the player into the truck but it flips in over and I'm not sure what to do. If you could give me a coding example that'd be great!
Answer by getyour411 · Jan 11, 2015 at 04:29 AM
Create an empty gameobject in the pos in the car you want player to be in. When trigger is fired, move player to the transform.pos/rot
player.transform.position = insideCar.transform.position;
The problem is the physics are colliding. Right before the player get's in the car. Do a playerObjectHER$$anonymous$$GetComponent().enabled = false; $$anonymous$$ake sure the player.transform.position is inside an update though, if not the car will drive off and leave him lmao. And, right after he gets out of the car, re enable the rigid body.
Okay sorry about this but I'm really new to unity and still am a bit confused in what to do. I have a OnTriggerEnter function which tries to call a function to transform.position, but it wont work. I'm also confused with the GetComponent().enabled = false; thing as well. Sorry! If you could just give me an example or something that would be great :D Sorry once again
Your answer
![](https://koobas.hobune.stream/wayback/20220613180032im_/https://answers.unity.com/themes/thub/images/avi.jpg)