[ad_1]
Hello everybody, I’m attempting to construct a cell supporting recreation. There are a number of static our bodies (with Box2Dcollider) within the scene and one dynamic physique (With Box2Dcollider) which might be dragged by a mouse.
When dragging the dynamic physique by way of the mouse at regular pace, it collides with different static our bodies which forestall its motion which is what I count on to occur. But, If I drag too quick it may surpass the collider of the static physique as if no collision occurred. Is there any strategy to forestall this?
Thank you upfront.
There is not any strategy to deal with any pace
Just restrict your dynamic objects’ pace or improve the physics-frame-rate (change system settings – not really useful) to catch the collision
As it’s the mouse motion, you’ll be able to attempt to create a “mouse-joint” to see if the draggable objects pace is proscribed
Can you share demo to verify?
Also did you attempt enabling Bullet?
Hi, @gadapchetvoi Thanks for the reply. I can restrict the pace utilizing a mouse-joint and keep away from the problem. Like I stated earlier than I’m constructing a web-mobile construct and the mouse-joint doesn’t work on mobiles.
Hello @smitpatel88. I attempted enabling bullet and it didn’t assist.
Here is the demo.
DemoProject.zip (1.6 MB)
Thank you.
That’s bizarre!
If it’s true then you’ll be able to emulate mouse joint by simulating the pull-force in replace(dt)
Something 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 are altering place by way of setPosition which isn’t the proper approach in case you are utilizing Physics.
both you take away physics and verify collision manually or use impulse to alter place.
Thank you for the reply, Can you please inform me what are the methods of manually checking collisions.
[ad_2]