Entity is jerking while rotating around X axis

I have given vertical input from joystick. How could we solve this conflict?

    if(this.dyVer > 0 && this.currentRotation.x > -0.2)

        this.entity.rotate(-this.rotationSpeedX * dt, 0,  0);

    else if(this.dyVer == 0 && this.currentRotation.x < 0)

        this.entity.rotate(this.rotationSpeedX * dt, 0,  0);

    else if(this.dyVer < 0 && this.currentRotation.x < 0.2)

        this.entity.rotate(this.rotationSpeedX * dt, 0,  0);

    else if(this.dyVer == 0 && this.currentRotation.x > 0)

        this.entity.rotate(-this.rotationSpeedX * dt, 0,  0);

How about I use Euler instead? Would that work?

if(this.dxHor > 0)

{

    nextEulerAngles = new pc.Vec3(0, 0, -30);

    quat = rotation.slerp(

    rotation,

    this.entity.getRotation().clone().setFromEulerAngles(

        nextEulerAngles.x,

        nextEulerAngles.y,

        nextEulerAngles.z

    ), 0.1);

    this.entity.setLocalRotation(quat);

}

Hi @yash_mehrotra,

Not sure what the issue may be, it’s hard without seeing the project. I imagine it may be something with your conditions that produce that.

Rotate on the entity should work as expected, here is a simple example that gets user input and rotates an entity:

https://developer.playcanvas.com/en/tutorials/rotating-objects-with-mouse/

Coded the rotation using eulers. It worked.