Ashika Umanga Umagiliya
Ashika Umanga Umagiliya

Reputation: 9158

Box2D : Check collision with the Joint?

As shown in the image I have implemented "blob" by connecting Circle shapes with "Distance Joints".

(refering JBox2D ContantVolume joint).

http://oi52.tinypic.com/2pz08z9.jpg

Is it possible to check whether other objects (in above case,circle in Magenta color) collide with the "Distance Joint Line" ?

thanks in advance.

Upvotes: 2

Views: 629

Answers (1)

SD1990
SD1990

Reputation: 808

Not sure how youve exactly implementing it, but if you have the x,y cooridinates of the Joints then most of the hard work is done. My advice would be to use one line and assume that line starts at 0, and ends at say 5. therefore that line goes from 0=> y <=5 and x = 0;

Next you could write an abstract function that takes the parameters (x1,x2,y1,y2) Inside that function is where you calculate the line equation. This equation is what you test. for instance your balls x and y will hit that line and then your software will throw up an alert or whatever you want the ball to do when it crosses or hits.

If you do the function abstract you can then implement this on all of the joints. Plus if you can add the x stuff the way youve added the y and constantly have that function update you can effectively have that blob floating and rotating in your space.

Hope this helps

Upvotes: 2

Related Questions