How to build a smart bezier curve?

This topic is 2005 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?

Share on other sites

I want to build a smart bezier curve like this. There are 100 targets (grid) in the map. I know the source point (Rocket), and the target point (Grid). How to calculate two control points to build a beautiful bezier curve which can not across the blue map?

"a beautiful bezier curve which" what?

Share on other sites

If you know it will only ever be 100 targets and the position of the source is constant, it might be easiest to just generate all 100 of them manually.

If you need to come up with an algorithmic solution you would probably want to base it on whatever is aesthetically pleasing to you, and that is going to take a lot of work.

Share on other sites

A variation of frobs idea:

Perhaps you can hard code the edge cases, and dynamically generate the easy cases where the ship/target are not near the edges?

You might also consider not using a curve, maybe doing it via physics?  A steering system that considers the edges as something to avoid would do their best to not touch them.  Though you do run into a problem where the object might not always make it perfectly to the point.  (Which you can kind of fake if you really need it.)

How are you determining the curve?  If you have points you know you want the thing to pass through, you could try catmull-rom, and then it's pretty easy to ensure that the catmull-rom control points are clamped to be inside the blue rectangle, which would mostly get you the curve you want.  (Not perfect, you'd still run into cases where you might go outside)

Another thing you might want to do, is instead of using some sort of parameterized curve, use a Dubin's Curve instead, and adjust start angle or the min radius as necessary so that the curve doesn't go outside the bounds.

Share on other sites

I am not quite sure I am following what you are asking here. You know two points. And you need two control points... I got that.

Why not just use the two points you have to form the two control points? If you are attempting to calculate trajectory, that is actually all you need unless your physics engine is some odd design.

If you mean, you do not want it to cross the map, I assume the grid, then you will want to use an invisible anchor that will collide with the grid, which effectively will cause the bezzier to adjust it's shape.

If you follow this idea, you will need to adjust it slightly so that the bezzier doesn't take such a large curve as well.

Edited by Tangletail

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 14
• 30
• 9
• 16
• 22