digitspro Posted December 1, 2016 Share Posted December 1, 2016 Hi there, Just a short intro, big fan of BabylonJS library! It got me excited to work on a new project of mine which is my first game. Bear with me now please, as I am fairly new to it, although I'd say I have done my studies on your API and documentation, which looks very attractive. The issue I am having is that when I scale objects bigger, collision goes wrong; Moving objects collide when they have already overlapped. What I expect is that the collision happens as soon as any face of a bounding box touches any face of the other bounding box The more I scale my objects, the worse things look. Please take a look at this playground which is hopefully self explanatory: http://www.babylonjs-playground.com/#10IKS#1 Further worse, uncomment line 29 which scales the ball bigger and see the obvious overlap with the wall. I messed with the methods and properties in the BoundingInfo but nothing helped. It does not look to me that the BoundingInfo is missing something anyway; as you can see, showBoundingBox = true (i.e. the wireframe) reveals nothing unexpected to my eyes. It's the whatever shape/thing that is used to calculate collision is what seems wrong and does not seem to update with the scaled ball. Shouldn't it? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 1, 2016 Share Posted December 1, 2016 Hello you are using collisions engine here and not physics so no need to setup physics info Collisions engine is a lightweight system that does not support all the feature of the physics engine and which is basically doing collisions between ellipsoids and meshes. In your case as you want to move the sphere, you need to update its ellipsoid: http://www.babylonjs-playground.com/#10IKS#3 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted December 2, 2016 Share Posted December 2, 2016 Yep. And line 47 scene.enablePhysics(); is NOT required... for this. Welcome to the forum, DigitsPro! Thanks for the nice playground demos, guys. Good collision testing without a physics engine. Carefully notice line 28, DP. The values are the RADIUS of the collision ellipsoid. MANY people (including me)... accidentally set the ellipsoid size == sphere size. It is a common mistake. Want to see a scene that DOES use a physics engine? Recently, I created a simple playground using a physics engine (CannonJS). It simply places a red block atop an icy sloped ramp, and it slides-off. After it falls some distance, it gets reset back-onto the ramp. (Camera panning and mousewheel zooming - all active). During the "reset", I null-out red block (sled) velocity/linearVelocity (sideways movement), and null-out angularVelocity (rotational movement)... but I do not reset the red box rotation to default value. SO, it lands on the ramp differently each reset. Fun! DP... check out lines 44 and 45. In those lines... an "impostor" is assigned to each physics-active mesh, which returns a ref to that imposter. I only needed the "sledbody" impostor returned to me... so I didn't bother getting a ref to "groundbody". I use sledbody inside the renderloop... often... for resetting the red box and its impostor. These "physics impostors" are similar to the "ellipsoids" that Deltakosh mentioned. Ellipsoids (built-in collision system) and impostors (physics engines like Oimo and Cannon) are not easy to display within a scene. They are... ghosts, in a way. All in all... Built-in collision system use ellipsoids (like an invisible sphere), checkCollisions (a flag), moveWithCollisions (a mesh mover), and sometimes intersectsMesh (a collision test)... stuff like that. Third party physics engines use impostors (invisible shapes), setPhysicsState(a flag and physics-properties setter), setLinearVelocity/setAngularVelocty (mesh movers) and also applyImpulse (another thruster-type of mesh mover). There are also "getters" for all the velocities, so you can monitor mesh impostors to see what they are doing. Both systems CAN use gravity, but only physics engines have settings for mass, friction, restitution (rebound/bounce), and honor/calculate momentum and inertia. (I hope I didn't say something incorrect). Take care, guys. Quote Link to comment Share on other sites More sharing options...
digitspro Posted December 3, 2016 Author Share Posted December 3, 2016 Thanks DeltaKosh for the given correction, and Wingnut for clearing up on built-in collision system vs third party physics engine. I am now clearer of which methods are associated with which system! Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.