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.