Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

Full Rotation 3rd Person Camera

$
0
0
I have a 'Spaceship' with full movement and rotation in a 3D world. Camera is attached to a 'CameraPiv' so i can get a 3rd Person Camera. This 'CameraPivot' can rotate arround 'Spaceship' and if i leftclick (set destination) the ship will rotate until its facing the same direction as 'CameraPiv'. When 'Spaceship' rotates, 'CameraPiv' will also rotate with his parent, but i want it to stay facing my destination, so I'm thinking in the following steps: - Detach 'CameraPiv' from 'Spaceship' - Smoothly point 'Spaceship' to Destination - Attach 'CameraPiv' to'Spaceship' - Move 'Spaceship' in direction its facing - and so on... //Spaceship script void Update () { if (Input.GetMouseButton(0)) { destAngle = CameraPiv.transform.localRotation; } CameraPiv.transform.SetParent(null, true); this.transform.localRotation = Quaternion.RotateTowards(this.transform.localRotation, destAngle, Time.deltaTime * ShipHandle); CameraPiv.transform.SetParent(this.transform, true); } 'Spaceship' points to my destinations, but 'CameraPiv' also rotates as it was always attached to 'Spaceship'... what am i doing wrong? Please help thanks in advance.

Viewing all articles
Browse latest Browse all 302

Trending Articles