Tween Documentation Fix

Hey there,

I was just reading the Tween documentation and noticed the sample codes need some fixing up after trying to work out why my tweens were acting strange.
https://developer.playcanvas.com/en/tutorials/tweening/

This sample using .to when it should be using .rotate

this.entity
.tween(this.entity.getLocalRotation())
.to(new pc.Vec3(180, 0, 180), 1.0, pc.Linear)
.loop(true)
.yoyo(true)
.start();

I haven’t checked the other samples, but it might be worth double checking them.

1 Like

@moderators on the repo it says:

If you are dealing with rotations you should use rotate instead of to. This takes euler angles and uses an internal quaternion to slerp between angles. For example:

entity.tween(entity.getLocalEulerAngles()).rotate({x: 0, y: 180, z: 0}, 1.0, pc.Linear);


Do both ways work?

Good spot @ed-spatialsauce!

Fixed in PR: https://github.com/playcanvas/developer.playcanvas.com/pull/242

1 Like