Mesh collision scene shaking

Hi,
I’ve setup a mesh collision floor with camera having a capsule as collider.
When I use my script to move with WASD keys, the scene starts shaking. How do i prevent this?
https://playcanvas.com/editor/scene/1604298
This project is part of a big scene where I took the floor mesh to demonstrate the issue. In the main project, the scene is shaking along with skipping some frames.

Looks fine in this video

Can you pls try the same in firefox, I’m unable to record video due to organization policies

I haven’t looked deeply, but it is probably because your capsule with controller script (where camera is a child) is a dynamic body, while your controller is using a entity.setPosition() on it. You need to teleport a dynamic body, or make it a kinematic one:

https://developer.playcanvas.com/en/user-manual/physics/physics-basics/

Otherwise, you need to use forces/impulses to control a dynamic body.

hi @LeXXik, thanks for the reply, I’m not updating its position using applyImpulse in camera controller. The controller script is working in VR mode and not in web mode.

Your child (camera) is trying to change the parent’s rotation directly, instead of using force/impulse to rotate it:

Generally, in a character controller, you don’t need to rotate the rigidbody. Simply push it towards the direction camera is facing. The visual model can rotate.

1 Like

My bad, let me change this and see.

Thanks a lot @LeXXik, it working without any shaking, but now the player is falling down, when I press W or S to move the player.

Probably rigidbody is allowed to be rotated? I’d start from checking if you set angular factor to zero on it.

1 Like