Node with convex mesh collider and rigid body disappearing after number of collisions

Hello Devs,

Here’s my scenario…

  • Create a torus with mesh collider with checked convex flag. Disabled Z axis of linear velocity in rigid body.
  • A sphere collider in the middle of screen with static rigibody
  • Box collider boundaries so torus doesn’t go out of view area

here’s the video (skip to last 10 seconds) : physics bug - YouTube

I am moving the body in script on onTouch systemEvent like this,

 onTouch(touch,event)
    {
        let screenWidth = view.getViewportRect().width;
        let isRight = touch.getLocationX() > screenWidth/2;

        console.log(touch.getLocationX(),touch.getLocationY());

        if(!isRight)
            this.body.applyImpulse(this.leftImpulseDirection.multiplyScalar(this.impulseScalar),Vec3.ZERO);
        else
            this.body.applyImpulse(this.rightImpulseDirection.multiplyScalar(this.impulseScalar),Vec3.ZERO);
        
        let v = new Vec3();
        this.body.getLinearVelocity(v);
        v.x= clamp(v.x,-this.maxVelAllowed,this.maxVelAllowed);
        v.y= clamp(v.y,-this.maxVelAllowed,this.maxVelAllowed);
        v.z = 0;
        this.body.setLinearVelocity(v);
    }

I have debugged whatever I could. Checked all components, everything seems to be present. I also tried resetting the position and clearing all velocities.
Kindly help me with this blocker.

Thanks.

Hi, could you give an reproduce demo?

Hello Jiaxin,

Thanks for responding. Here’s the project :
https://drive.google.com/file/d/1q3zupDKLU6sjx-9DlanPGKM9ndYkzNs6/view?usp=sharing

Open it using cocos creator 3.2.

Thanks

I tried many times and it was very difficult to reproduce this problem, and I couldn’t get a clear cause of the problem. But it seems that there is a division by zero, which may be the same as you set the position every time.

1 Like

No problem. Thanks for your time man!! appreciated. I will create a new project. Hopefully it should work fine. I will update you guys if I find something. Thanks.