Jump to content

How i can detected collisions with Oimjs


Gamerazor
 Share

Recommended Posts

Hello. I have seen in other post that oimjs doesn't detect collisions and this is a big problem for tha game that I'm doing that is similar to Arkanoid but in 3D. I need impulse the ball when collide with the bar and need detect when the ball collide with some box for it disappears. How can I resove this problem? Is there any alternative with oimjs to detect collisions?

Link to comment
Share on other sites

Hello!
 

This is not true: OIMO.js is perfectly suited to detect collisions between spheres and boxes:

 

You can have a look at this post for more info:

http://www.sitepoint.com/understanding-collisions-physics-babylon-js-oimo-js/?utm_content=buffer62396&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

Link to comment
Share on other sites

Hi GR

Maybe take a look at this...

http://playground.babylonjs.com/#1VNAYW#1

In this demo, the target has been setPhysicsState... meaning the ball bounces off of it.  BUT... if you had many targets stacked atop each other (like Arkanoid), and ALL their physics were set... then they might rub together and cause over-colliding.  You may want to keep a small space between all targets.

The demo below uses no physics state for target.  Its easier to place many targets stacked atop each other..... without massive target colliding... but there is nothing to push the ball back towards the paddle when a target collide-and-dispose-it happens.  In other words, if the ball power is rather high, then the ball can travel upward past the target.

http://playground.babylonjs.com/#1VNAYW

Maybe... if intersect...

1. Dispose of the intersected target

2. Apply impulse on the ball - downward toward paddle.  Ideally, the force is the perfect inverse direction and velocity (a proper rebound).

You might find that putting a smaller box or plane INSIDE-OF each target box... and setPhysicsState on the hidden inside object, but NOT on the target box itself... might be useful.  The ball will sink into the target a certain amount... before the intersect triggers.  (Might look cooler and prevent unwanted target-to-target collisions.)

I assume you know that this game could be built WITHOUT using a physics engine, yes?  A bit of math from the early pong games, mixed with a bit of homemade rubber for velocities (more math), and you could do the paddle->ball reactions yourself.  And, the game would be MUCH faster, I aimlessly predict.  ;)

I hope some of this stuff helps.  Be well.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...