Hi There.
I’ve got a third person character controller. Contained within is a space ship, and eventually I’d like to maybe add the option of updating and swapping out various prefab meshes.
In the short term, I’d like to be able to detect if the 3rd person character controller is turning left and rotate the ship in its X axis so it looks a little like it’s “banking” when it turns.
So far I’ve tried (the woefully inadequate)
// this doesn't work in any way shape or form, but
// since I'm kinda 'flying blind' it indicates what I'm trying for
var ship = GameObject.Find("ship");
if (GetDirection()[0] > 0) {
ship.Rotation.X += 10;
} else if (GetDirection()[0] < 0) {
ship.Rotation.X -= 10;
} else {
ship.Rotation.X = 270;
}
This is based on the default 3rd Person CC
thanks! this is great :)
– anon1534777An additional comment: it may be better to assign the whole localEulerAngles at once to avoid drift over time - just change the last line to: model.localEulerAngles = Vector3(0, 0, bank);
– aldonaletto