Apply lerpAngle to entity

I understand how lerp and lerpAngle are supposed to work, I just can’t figure out how to apply them to an entity in my scene. In this project: https://playcanvas.com/editor/scene/596960 I need the pointer to lerp from whatever angle it’s z rotation is back to 0. I can get it to snap back to position but I want it to look more natural.

EDIT: I tried using the example @BenBean303 gave in this post Lerping camera motion example please, but it doesn’t seem to work with lerpAngle.

Looking at the docs, there doesn’t seem to be a Vec3.lerpAngle – only math.lerpAngle, which is why you’re getting an error. From context it seems like you would want to use the Tween library, which would allow you to do something like:

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

Which will smoothly rotate an entity back to 0, 0, 0.

There’s obviously more to this. I tried:

if(this.stopped)
{
    {
        this.pointer.tween(this.pointer.getLocalRotation()).rotate({x: 0, y: 0, z: 0}, 1, pc.linear); 
    }
};

but it didn’t work. Would I need to make a script to attach to the entity I want to tween, or can I do it the way I tried above and tween the entity through any other script?

EDIT: Got it, needed to add .start() to the tween, getting an error saying this.easing is not a function from the tween.js though.

Use pc.Linear instead of pc.linear for easing.

That was it, but the movement still doesn’t seem smooth like it does in the examples.