|
|
|
|
Reply From: |
avencherus |
You may want to look into Craig Reynold’s work on steering.
A summary article of some of it can be found here: Understanding Steering Behaviors: Wander | Envato Tuts+
You might be interested in the wander algorithm.
Great avencherus, thank you very much too…i’ll look into it.
Bishop | 2017-05-25 13:20
Oh, for AI, definitely you will want to implement behaviors.
No problem. I see that I didn’t understand your initial question. You want to interpolate between waypoints.
A Path2D would be best if you want to easily implement a curve inside the editor, and you would get smoother rotation if you create a curve.
If it was to be done in code, then interpolation between two way points will give you the distance, based on some alpha value (0 to 100%).
The rotation can be calculated by using the angle of that difference vector. Then atan2(y,x) or vector.angle() should give you the angle towards the next waypoint. Adding and offset of PI in many cases, to orient the sprite to face along that path.
var difference = B - A
var alpha = .5 # Some distance between 0 and 1
var new_waypoint = A + difference * alpha
var new_angle = difference.angle() + PI
avencherus | 2017-05-25 16:09
Yes, thank you very much avencherus,…easier solution for this game is OK,
this game is a simple boat race with a track boundaries and a max 3 NPC boats…i’m still a beginner in GDscript.
…i really appreciate help from as!!
Bishop | 2017-05-25 17:25
@eons
Yes, this is an excellent source for education.
Bishop | 2017-05-25 17:33
You’re welcome Bishop, hope it bears fruit for you. Good luck with your adventure. X)
avencherus | 2017-05-25 17:34