This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

What is the best way to implement waypoints?...I'd need "fire" waypoint from a boat at a certain distance ( image bellow ) and change boat rotation ( and speed) in every "shooted" waypoint for the possibility do the corners.
Thank all for help
enter image description here

in Engine by (454 points)

3 Answers

+2 votes
Best answer

For this case, maybe a Path2D can help, then you can use a PathFollow2Ds to set the position of the waypoint areas changing the offsets, should be easy to edit this way.

You can do this with a single PathFollow2D too or just using the curve and some points/distance you set in another way.

by (7,954 points)
selected by

Thank you very much eons,
and that's the great solution...any chance how I get the position of the individual Path2D points...
i'll get to them?......i thought it could be ( Path2D points ) directly as a target for a boat or spaceship and waypoint for rotation(faceing) and changing speed...just an idea......more on image bellow

enter image description here

If you use PathFollow2Ds you can get a position when changing the offset.

If using just the Path2D, you will need to work on the Curve2D (get_curve).
You can get a point position or the position based on an offset (distance from the origin of the curve), I think all the points on the curve are relative to the Path2D, so, keep that in mind when checking position.

Look at the Curve2D documentation for more details

Thank you very much eons....I will go this way

0 votes

either an array of vector2 positions or place a bunch of node2ds and iterate through them :)

by (290 points)

Thanks , I have this ,but I'm still looking for another and maybe a better solution like spawning "shooting" waypoints from boat.
enter image description here

+1 vote

You may want to look into Craig Reynold's work on steering.

A summary article of some of it can be found here:

You might be interested in the wander algorithm.

by (5,286 points)

Great avencherus, thank you very much too...i'll look into it.

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

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!!

Yes, this is an excellent source for education.

You're welcome Bishop, hope it bears fruit for you. Good luck with your adventure. X)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.