RigidBody cant work when i use entity.SetPosition

i try to move my character with point and click control, but i want my player collide with any obstacle like box or someting. check the sample scene
but, my character through the wall.

i’ve try with this.playerEntity.rigidbody.teleport(newPosition); like in my sample scene. but its make the charater move laggy, not smooth.

if (this.direction.lengthSq() > 0) {
        // Move in the direction at a set speed
        var d = this.playerSpeed * dt;
        var newPosition = PointAndClick.newPosition;
        // Position
        // Rigid body
        this.distanceToTravel -= d;
        // If we have reached our destination, clamp the position 
        // and reset the direction
        if (this.distanceToTravel <= 0) {
            this.direction.set(0, 0, 0);

can anybody help me

Hi @Gagan_Sukmawan, teleport is usually the way to do it when you want to use dynamic. Can you please show us what you mean by “laggy” movement? setPosition will not work in your usecase since you are trying to use dynamic rigidbodies.



i mean , my chracter moves not going smooth.


here we go, i’ve been change the code.
u can try there

for a while (when we launch the game) the character’s move is not smooth

Hey @Gagan_Sukmawan,

I’ve just had a look at your project. I didn’t find the movement laggy as such, but if you mean that the user needs to keep holding down the mouse button to make the position move rather than click to go to a certain point like before, pathfinding might be the best way to fix this problem, especially since you want your character to be able to navigate around rigid bodies. For this, you can check out either PathFinding3D.js, @Leonidas’s extension, or this thread.

I hope this helps.

1 Like

Hy @DevilZ thanks for your answer. i’ll try pathfinding.

but, video lagg
thats what i mean laggy,

Hi @Gagan_Sukmawan and welcome! I’ve had a similar problem and it was caused because I set the camera position along with the player position. The solution may be to set the camera position in a postUpdate function or to make the camera entity as a child of the player entity and not use the script for this anymore.


Superb broo @Albertos … u solve it. thanks


1 Like