- Home /
How would I put a first person player become child to a vehicle?
I am trying to set a first person player into a vehicle which will then go into a 3rd person view of a vehicle. How would I trigger the player to become child to the vehicle and switch to the car's camera?
Answer by MicroEyes · Jul 12, 2013 at 12:08 PM
GameObject m_playerRef;
GameObject m_vehicleRef;
void DoIt()
{
m_playerRef = GameObject.FindObjectByTag("Player");
m_vehicleRef = GameObject.FindObjectByTag("Vehicle");
m_playerRef.transform.parent = m_vehicle.transform; //Parenting Player to Vehicle here.
}
Answer by amphoterik · Jul 12, 2013 at 12:04 PM
If it were me, I would have a camera on the vehicle already (or a place to spawn a camera on the vehicle). When the player entered the vehicle, I would disable the motor script and camera on it. Then I would enable the motor script and camera on the vehicle. when exiting the vehicle, just reverse it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613105951im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
how do i trigger a camera and a sound 1 Answer
Given a quaternion, how do I modify it to zero rotations about certain axes? 1 Answer
Restraining movement to camera bounds 1 Answer
Need camera to follow player, but not the player's rotation. 13 Answers