What to do to make Tween rotate the object +90 degrees? (offset)

Hello

What to do to make Tween rotate the object +90 degrees? (offset)

var toRot = new Quat().fromEuler(0, 0, 90);
iron.system.Tween.to({
				target: o.transform,
				props: { rot: toRot },
				duration: t,
				ease: e,
				tick: update,
				done: done
			});

best regards
1 Like

I created a function that rotates the Empty object and takes its rotation.

Having code in Haxe, I would create a Logic Node for this.

2 Likes

Is this to smooth the rotation?

Yes, I want to use Tween to rotate an object e.g. +90 degrees in the Z axis.

I tried the code below but it doesn’t work well, the object rotates fine but the second time it goes back to the previous rotation.

var vRot = o.transform.rot.getEuler();
		vRot.x += v1.x;
		vRot.y += v1.y;
		vRot.z += v1.z;

		var v2 = new Quat().fromEuler(vRot.x, vRot.y, vRot.z);	
		
		iron.system.Tween.to({
				target: o.transform,
				props: { rot: v2 },
				duration: t,
				ease: e,
				tick: update,
				done: done
			});

It would be best to use the Quaternionion for this, but I failed.

I think you can use Mix node for this, but i don’t found a way to make it rotate for the nearest angle yet. Maybe there is other way to make this better.

For example, you can use mix node with 0.1 factor with the actual rotation and the next rotation connected to it, and the values will be aproached smoothly.