(Solveed) How to make object face same direction as its parent?
This might sound quite simple, but I just cant get it done, so how would I make my object's (camera) rotation the same as the parent of this object, I have a game where you enter a car you can look around with your mouse and drive, but when you don't move the mouse the camera should rotate with the parent of the camera, in this case the car, I know I could just disable this script while movement doesn't happen but I'd like the camera to not look like its glued in place, so it would have a little movement for an example up and down, exactly like the early camera in my summer car. (link to one vid with the camera: https://www.youtube.com/watch?v=mXLameO7hsg)
public float speedH = 2.00f;
public float speedV = 2.00f;
public Transform car;
public Transform pivot;
private float pitch = 0.00f;
private float yaw = 0.00f;
void Update()
{
float eulerY = car.eulerAngles.y;
transform.eulerAngles = new Vector3 (pitch, eulerY + yaw, 0.0f);
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
if (pitch >= 90)
{
pitch = 90;
}
if (pitch <= -90)
{
pitch = -90;
}
}
Edit: Working now, all it needed was to + the yaw to y of the car lmao I couln't figure that out faster...
Your answer
Follow this Question
Related Questions
I cannot move my camera in the Game mode 0 Answers
Make Camera follow rotation of 2 Players 1 Answer
CineMachine Camera Movement is inverse 1 Answer
Spyro Like Camera Follow 0 Answers
viewing on the Mouse Y axis not working. 0 Answers