Rigidbody passes through walls

Hello. In the new project, when the character moves, it passes through the walls. If you release the movement button, the wall will push it out. This does not happen on a weak computer. I tried to reduce the scale of the vector, it helps, but then the character moves too slowly. Can you tell me the solution to the problem?

    if(this.app.keyboard.isPressed(pc.KEY_UP)){
        const forward = this.player.forward
        let x = 0
        let z = 0
        x -= forward.x
        z -= forward.z
 
        const pos = new pc.Vec3(x * dt, 0, z * dt)
        pos.normalize().scale(0.0009)
        pos.add(this.player.getPosition())
        this.player.rigidbody.teleport(pos)

Hi @sergey_ch,

To have the physics sim calculate the correct position of a body so it doesn’t pass through walls you should use forces or velocities to move your player entity.

Teleport overrides the position the physics simulation calculates each step.

2 Likes

But in this example teleport is used and the obstacles slow down the character.
Third Person Controller

Can you share some details on how you have your scene setup?

What kind of bodies are used for walls, for your player etc.

If you have everything set as the third person controller it should work, since you are using the same code.

@sergey_ch
Make sure your objects are on same physics layer, also you could look into continuous collision detection CCD.
Also please share the project if possible, its very hard to identify problem.