Why turn delay?

Hello. When I use the rotate function, the rotation occurs immediately. But after moving forward, a new turn does not occur immediately, but after a few seconds. Tell me what the reason is?

Mover.prototype.rotation = function(direction){
    const dir = direction === 'left' ? 1 : -1
    this.entity.rotate(0,3*dir,0)
}
Mover.prototype.walk = function(dt){

const forward = this.entity.forward.clone().scale(-0.0008)
const currentPos = this.entity.getPosition().clone()

 const pos = this.entity.getPosition().add(forward)
 this.entity.rigidbody.teleport(pos)
}

And yet, you do not know why when colliding with a rigid wall, the object continues to pass inside, but if you stop in time, it will push back.

Hi @sergey_ch,

The issue here is you use the regular pc.Entity rotate() method when your entity is controlled by the physics simulation.

You will have to find another way to rotate your entity, or at least add the rotation in your rigidbody.teleport() method, so it gets calculated by the physics sim.

2 Likes

Understood, thank you. Do you have a sample code for such a rotation of the body?