Friday, October 7, 2022
HomeGame DevelopmentFast-paced dynamic physique passes by collider of static our bodies - Cocos...

Fast-paced dynamic physique passes by collider of static our bodies – Cocos Creator


Hey everybody, I’m making an attempt to construct a cellular supporting recreation. There are a number of static our bodies (with Box2Dcollider) within the scene and one dynamic physique (With Box2Dcollider) which may be dragged by a mouse.
When dragging the dynamic physique by the mouse at regular pace, it collides with different static our bodies which forestall its motion which is what I count on to occur. However, If I drag too quick it may possibly surpass the collider of the static physique as if no collision occurred. Is there any approach to forestall this?

Thanks prematurely.


There isn’t a approach to deal with any pace
Simply restrict your dynamic objects’ pace or enhance the physics-frame-rate (change system settings – not beneficial) to catch the collision

Because it’s the mouse motion, you possibly can attempt to create a “mouse-joint” to see if the draggable objects pace is proscribed

Are you able to share demo to test?
Additionally did you strive enabling Bullet?

Hello, @gadapchetvoi Thanks for the reply. I can restrict the pace utilizing a mouse-joint and keep away from the difficulty. Like I mentioned earlier than I’m constructing a web-mobile construct and the mouse-joint doesn’t work on mobiles.

Hey @smitpatel88. I attempted enabling bullet and it didn’t assist.
Right here is the demo.
DemoProject.zip (1.6 MB)

Thanks.

That’s bizarre!
If it’s true then you possibly can emulate mouse joint by simulating the pull-force in replace(dt)
One thing like:

pullingVector = ....... // calculate from place of mouse & objects
forceIntensity = .... // calculate from mouse distance
obj.rigidBody.applyLinearImpulse( pullingVector.mul(forceIntensity), cc.Vec2.ZERO, true );

I checked the demo.
You might be altering place through setPosition which isn’t the proper means in case you are utilizing Physics.
both you take away physics and test collision manually or use impulse to alter place.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments