Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to build a smart bezier curve?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 FiberCore   Members   -  Reputation: 103

Like
0Likes
Like

Posted 18 April 2014 - 08:34 AM

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?

 

bzH.png



Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 13684

Like
0Likes
Like

Posted 18 April 2014 - 09:27 AM

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?

#3 frob   Moderators   -  Reputation: 22289

Like
0Likes
Like

Posted 18 April 2014 - 11:15 AM

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. 


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#4 ferrous   Members   -  Reputation: 2075

Like
1Likes
Like

Posted 18 April 2014 - 12:12 PM

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. 



#5 Tangletail   Members   -  Reputation: 188

Like
0Likes
Like

Posted 18 April 2014 - 10:31 PM

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, 18 April 2014 - 10:35 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS