Problem with grouped body clipping through floor?

Discuss issues specific to the Flash/AS3 port of Box2D
freshmancoder
Posts: 3
Joined: Thu Mar 21, 2013 7:47 am

Problem with grouped body clipping through floor?

Postby freshmancoder » Thu Mar 21, 2013 7:51 am

I'm learning Box2D, and for my program I am trying to design a car from randomly generated triangles (I was inspired from the boxcar2D thing). Now I've gotten past the part where the body is generated from different triangles, but when I try to add wheels something weird happens. The wheels collide with the land beneath it but the body of my car just passes through it. Here's a picture.

Sometimes it does this, other times it just balances on a tip of one triangle, and I can't figure out what's wrong.
Image

EDIT: It happens even if the wheel isn't there

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Problem with grouped body clipping through floor?

Postby irresistible force » Thu Mar 21, 2013 4:13 pm

Are you giving the vertices of the triangles in counter-clockwise order?

freshmancoder
Posts: 3
Joined: Thu Mar 21, 2013 7:47 am

Re: Problem with grouped body clipping through floor?

Postby freshmancoder » Sat Mar 30, 2013 9:54 am

Yes, the vertices of the triangle are being given in the correct order. Is it a problem with piecing all of the triangles together for the entire car?

jayther
Posts: 266
Joined: Sun Oct 25, 2009 3:28 am
Contact:

Re: Problem with grouped body clipping through floor?

Postby jayther » Mon Apr 01, 2013 12:54 am

Did you try reversing the vertices order? The counter-clockwise order applies to the right-handed coordinate system (positive Y is up). If you're doing screen dimensions (positive Y is down i.e. left-handed coordinate system), then the order has to be clockwise.

freshmancoder
Posts: 3
Joined: Thu Mar 21, 2013 7:47 am

Re: Problem with grouped body clipping through floor?

Postby freshmancoder » Wed Apr 03, 2013 11:22 am

Thanks irresistible force and jayther for helping! For anyone following this thread: jayther hit the nail on the head. I simply switched the order of the vertices of the triangle and that was all it took to fix my problem!


Return to “Flash”



Who is online

Users browsing this forum: No registered users and 2 guests