Gimbal issue on rotation

Hey everyone,
I want to rotate and move the player based on points defined in player path. I have used below code but there is gimbal issue in the beginning due to let entityRotation = new pc.Vec3(0, angleInDegree + 270, 0); this line . How can I resolve the same.

var PlayerPath = pc.createScript('playerPath');

PlayerPath.attributes.add("pathRoot", { type: "entity", title: "Path Root" });
PlayerPath.attributes.add("playerSpeed", { type: "number", default: 1 });

PlayerPath.prototype.initialize = function () {
    this.movePlayer(0);
};

PlayerPath.prototype.movePlayer = function (currentIndex) {
    currentIndex = currentIndex || 0;
    let nextIndex = (currentIndex + 1) % this.pathRoot.children.length;
    let nextPos = this.pathRoot.children[nextIndex].getPosition();
    let currentPos = this.entity.getLocalPosition();

    let distance = currentPos.distance(nextPos);
    let time = distance / this.playerSpeed;

    let direction = new pc.Vec3().sub2(nextPos, currentPos).normalize();
    let angleRadians = Math.atan2(direction.z, direction.x);
    let angleInDegree = -angleRadians * (180 / Math.PI); // Negate the angle

    let entityRotation = new pc.Vec3(0, angleInDegree + 270, 0);
    this.entity.tween(this.entity.getLocalEulerAngles())
        .rotate(entityRotation, 0.5, pc.Linear)
        .start();

    this.entity.tween(this.entity.getLocalPosition())
        .to(nextPos, time, pc.Linear)
        .onComplete(() => {
            this.movePlayer(nextIndex);
        })
        .start();
}

Thank you

Hi @gouthamamin!

I don’t know what ‘gimbal’ means and Google Translate won’t help me.

I’m also curious what the purpose of the specific code is.

let entityRotation = new pc.Vec3(0, angleInDegree + 270, 0);

Is there an offset somewhere that requires the extra 270?