- Home /
Question by
11tomi12 · Dec 27, 2017 at 02:04 PM ·
cameravector33rd person camera
Moving 3rd person camera around car
Hi I made a simple script that allows the user to move the camera with mouse movement. It works like a charm, but now I would like to add a starting position(directly behind the car).
Since the car is moving I would need to calculate the mouseX and mouseY positions from the car current position. I have no idea, how I could archive that. Also, how could I move the camera, when the car is rotating?
Camera mouse movement script:
mouseX -= Input.GetAxis("Mouse Y") * sensitivity;
mouseY += Input.GetAxis("Mouse X") * sensitivity;
mouseX = Mathf.Clamp(mouseX, minMaxXAngle[0], minMaxXAngle[1]);
Vector3 targetR = new Vector3(mouseX, mouseY);
transform.eulerAngles = targetR;
transform.position = target.position - transform.forward * distanceDamp;
//Debug.Log(target.transform.rotation.x + " " + target.transform.rotation.x);
Vector3 temp = transform.position;
temp.y += 1;
Comment
Answer by Creatom_Games · Dec 30, 2017 at 09:50 PM
Try making the camera a child of the car. Then you wont have to worry about calculating the new position of the camera.