Iām creating positions in 3D space at witch I want a camera to be positioned, and decided to use Tween.js for interpolating between the current camera position and the target position.
But now I want to also use the target Ā“s rotation.
I tried something like this:
this._rotationTween = new Tween(this.gameObject.quaternion);
this._rotationTween.easing(Easing.Quadratic.InOut);
this._rotationTween?.to(newView.quaternion, 1000).start();
The same technique i applied to positions, but when it comes to rotations, it just looks like it never properly updates. Can somebody tell me what Iām doing wrong?
PD: I tried the same with this.gameObject.rotation but the same behaviour happens
It kinda works, the tween part at least. Now question is, when it gets executed, I can se that the camera rotates down until it ends looking down the opposite way, I tried by inverting the target quaternion, but it doesnāt affect the result.
Iām back :gentleblob: @marcel the thing its the next:
My idea is to mark certain locations inside Unity Editor by using empty objects (sometimes I want both position and rotation) so that I can loop between those, āextractā both properties and assign it to whatever I need at that moment (in this case is the camera, but it doesnāt have to be always).
Notes: Iām attaching two images, in this scene I have 2 buttons (the ones with numbers) that triggers a function which does exactly what I said above, the only problem is that the camera appears to look at the āreverseā.
Also important to note, I know that I can use the lookAt component, but Iām trying to avoid it on purpose, since as I said, it doesnāt have to be the camera all the times, Iām just using it to orient the forward vector of the empties towards a certain target inside Unity (thus the name of the objects inside the hierarchy in the first image).
Hereās the video to show exactly what is happening:
Hi! its me again with an update.
I Succeeded in fixing the thing, but I wanted to share my story for the case it happends to someone.
So the thing is: If you use the āstandart methodā directly on the camera object, weird things can happen (I disabled other components such as orbitControls.ts to be sure).
In this example, āviewPositionsā is an array which inside unity would have references to empty objects, from witch I pretend to source their transformations (positions, and local rotation).
While fooling around trying things, at one point the interpolation distorted the render itself, at witch a lamp in my head turned on. I thought at that moment: What would happen if, instead of adding the component to the same object where the camera component is, I add it to an empty object which would serve as the parent to the ācameraā object?
And boom it worked just as intended!
If someone can explain to me why is it like that I would really love it!
So thatās all :gentleblob:
donāt know if iām missing something but the example mixes Eulers (new Tween(this.gameObject.rotation)) and Quaternions (const anotherRotation = new Quaternion()...) so the tweened values do not make sense.
Thank you so much! yourāe a hero
Yes I noticed the thing about the mixing between Eulers and Quaternions, but Iāll try this tomorrow, directly on the camera and iāll be back with a follow up!
Where do we? Typically we use quaternion. Three just exposes both ārotationā and āquaternionā which means that unfortunately itās easy to confuse coming from Unity