
[ad_1]
I’ve a Game Object with a digicam on it. I’m attempting to purpose the digicam at a goal but additionally attempting to maintain the goal pointing up the proper method within the digicam’s view. In this case its a picture or merchandise of textual content positioned statically in vary of the digicam.
I’m utilizing Quaternion.LookRotation
in an similar method as described on the documentation web page
This works effectively however the digicam will begin to present a slanted view of the thing. As although it has been rotated on the Z axis of rotation.
I’d wish to right this such that the textual content/picture seems the proper method up. I can obtain this by manually including(multiplication after all) a Z rotation worth to the results of LookRotation
however that is static.
I’d like a method to dynamically calculate this.
I’ve tried, inspecting the UP vectors of the digicam and goal, subtracting the Quaternions of their world rotations to account for this twist, messing round with FromToRotation and many others.
But I’m undecided what I’m meant to be doing and I assume there’s a mathematical method to do that.
My ideas have turned to desirous about drone cameras or Camera Gimbals however to date my looking has simply result in a bunch of random makes an attempt that give wild values or a digicam that simply spins actually quick with unusual suggestions loops.
Is there a method to do that?
[ad_2]