I’ve been done plenty of testing and research with Level Director and bezier curves.
I have some bezier curves (nothing extreme, just some nice hills up and down).
I have a rectangle that slides up and down the hills.
The problem is that occasionally the corner of the rectangle gets stuck and flips the rectangle (not desired effect).
Digging into the function in the Level Editor helper file I can see that the curve is split into segments and little overlapping long-triangles are created (sort of like a sawtooth). This is still causing flipping at certain points and it’s also horrible because the object can’t go backwards over the curve.
Doing some more research I’ve learned that this is a common issue/question with Box2d and with ghost vertices.
Is there anyway that Level Director’s algorithm could be upgraded to use this for bezier curved physics? I think it would improve the overall result of physics applied to bezier curves.
Yes it was quite a challenge getting the Bezier curves working and even more difficult when you add physics to the equation.
It has actually been on my list for a while to revisit the Bezier curve creation as I always felt there was a better way to implement it but back then (approx. 2 years ago) my Lua skills were limited and this was also prior to Graphics 2.0.
I’ll try and find some time to take a look at this.
FYI - if you set the physics shape on your object to be a circle or a shape similar to a rounded rectangle this also helps eliminate the problem.
Hopefully the new changes I sent will work but I’m a little concerned about the 32 vertices limit on chain edges as it appears to work with more than 32 in the simulator.
Yeah I tried rounding the corners of the shape but it would still snag.
I looking into using a circle but that doesn’t work because I can’t offset the circle shape on the object (a long rectangle) so it would be in the center which won’t work for what I’m trying to achieve.
I’m also curious about the 32 vertices limit and wonder if it’s a Corona limit (I couldn’t find any mention of a 32 vertices limit in box2d documentation).
I’ve only tested it on one device (a 3 year old Android phone) and it seems to work fine.
In my test I had 4 bezier curves to create a longer level and it had no problems. Thanks for the quick turn-around on this. I’ll let you know if I have any issues.
Yes I would be very interested about your code.
I am struggling to do the following (please open the attachment):
Please have a look at the pic.
For a bouncing ball on a bezier curver I would like to dynamically calculate the absolute distance between the anchor point of the ball and the corresponding coordinate on the bezier curve at any given x while the result is the distance in pixels of y.
The requirement would be that at any given x one could calculate the corresponding coordinates on the bezier curve.
Do you think that it is possible and does anyone have an idea how to do it?
Yes it was quite a challenge getting the Bezier curves working and even more difficult when you add physics to the equation.
It has actually been on my list for a while to revisit the Bezier curve creation as I always felt there was a better way to implement it but back then (approx. 2 years ago) my Lua skills were limited and this was also prior to Graphics 2.0.
I’ll try and find some time to take a look at this.
FYI - if you set the physics shape on your object to be a circle or a shape similar to a rounded rectangle this also helps eliminate the problem.
Hopefully the new changes I sent will work but I’m a little concerned about the 32 vertices limit on chain edges as it appears to work with more than 32 in the simulator.
Yeah I tried rounding the corners of the shape but it would still snag.
I looking into using a circle but that doesn’t work because I can’t offset the circle shape on the object (a long rectangle) so it would be in the center which won’t work for what I’m trying to achieve.
I’m also curious about the 32 vertices limit and wonder if it’s a Corona limit (I couldn’t find any mention of a 32 vertices limit in box2d documentation).
I’ve only tested it on one device (a 3 year old Android phone) and it seems to work fine.
In my test I had 4 bezier curves to create a longer level and it had no problems. Thanks for the quick turn-around on this. I’ll let you know if I have any issues.