I got a slightly complex cameras-player setup, which I’ll try to explain:
OuterSpaceCam: renders first, renders outher space (low poly), sort of a 3d skybox
the OuterSpaceCam is a child of a transform.
SceneCam: renders 2nd, renders the normal scene
the SceneCam is a child of the player (character controller), the SceneCam locally only rotates up and down (though I don’t think that really matters for this).
OuterSpaceCam.localRotation should always be equal to SceneCam.rotation (this is done on purpose, I actually rotate the OuterSpaceCam.parent so that these rotations are equal, it’s OuterSpaceCam.parent only purpose.)
I do OuterSpaceCam.localRotation = SceneCam .rotation; every lateupdate. so that the space cam moves correctly with SceneCam which is controlled by the player.
anway, when I go from planet to planet, I want the local scene upaxis to be away from the planet, so in the outer space scene it matches the normal of the position on the surface of the planet I’m on.
So I have to rotate both the player and OuterSpaceCam.parent (withouth OuterSpaceCam itself).
So I do this (in the OuterSpaceCam) and that works:
var CamRotation = transform.rotation; transform.parent.LookAt(transform.parent.position+transform.parent.forward,planetNormal); transform.parent.LookAt(transform.parent.position+transform.parent.right,planetNormal); transform.parent.LookAt(transform.parent.position-transform.parent.right,hit.normal); transform.rotation = CamRotation; //tot hier is het allesinds juist
That makes the OuterSpaceCam.parent rotate so it should be correct, and keeps the OuterSpaceCam.rotation intact so the camera is still correctly orientated.
now I used to do this which rotates the SceneCam:
that works, but I want to rotate the player instead of the SceneCam, I actually want the SceneCam localRotation to stay intact.
So I do this, but it doesn’t work:
rotationTarget.parent.rotation = transform.localRotation; rotationTarget.parent.RotateAround(rotationTarget.parent.right, 90); //cause the SceneCam has a localRotation of Quaternion.Euler(-90, 0, 0)
So, anyone who understands what I’m saying, and sees what’s wrong ?
(My god, this must the worst understandable question I’ve ever asked)