I was wondering if there was a way to make flying enemies follow unique paths aside from just using path finding to follow the player around. Like say if during an attack, I want an event to swoop down and then swoop back up in an inverted bell curve Kind of way, how would I go about doing that?
I’d really appreciate if anyone could share any tips or tutorials that could be useful ![]()
Hello @Thedevcj
In year 2020, when i was creating my first GDevelop game “Paper Plane”, i asked the same question.
I finded in the documentation the path finding function but not the possibility that an object follow a precise path.
I bypassed the problem creating an sprite object (a point in fact) and putting many of it to form a path.
Then with events, i force my principal sprite to follow these points using the function “choose the nearest object” or something like that.
Xierra
That sounds really good, the thing is, I plan for these enemies to work in swarms of 2 or 3 so having individual points or oaths could seriously confuse them and mess up the whole system, is there any other way to simulate something like that?
You could do it mathematically, this way you can configure different patterns just by changing variables.
Basically you would give the enemy some variables to represent different components of the movement. There’s a lot of different ways to go about it, which partially depends on how you are moving them in the first place.
To get nice curves the easiest way (in my opinion) would be to use forces. You can use basic 2d forces or Physics (but not both - if you don’t need collisions where things bounce off each other, then you can just use the basic force events which are already available)
For a bell curve you could do something like have the enemy move along X at a constant rate by applying a permanent force on X, but then have a Y force that changes. So you’d have an initial Y force of say -100, which is stored in a variable. Then you have another variable such as “YForceDelta” that represents the change in Y force. Let’s say its set to 5 - each frame, you would apply the Y force to the object, then add YForceDelta to the YForce variable. So next frame it will be -95, then -90, and so on, until it goes into positive numbers eventually.
You would have to play around with it to get things just right, and remember that instant force only moves the object for a single frame, while permanent force is more like momentum, where adding new permanent forces will be cumulative.
You can use this on both X and Y to get various effects like enemies that spiral across the screen.
What kind of artificial reply is this ![]()
It’s not artificial, but it is too short. I was wondering why no one had mentioned the curved movement extension and that’s what Zero’s link went to, an official editor example of it. I’m not a fan of empty replies with just a link though. They don’t help future searches and they force people to click on them just to find out what it’s all about.
I’m messing with him XD
I don’t know whether you’re making a platformer or an isometric game, but in my game I don’t use pathfinding behavior.
Each enemy has 2 raycasts: one prevents collisions and its lenght is equal to sprite/collision box, and another one that points toward the player when it gets close.
For the flying enemy that targets the player (therefore storing the Y position), once it reaches a certain distance I generally use curved pathfinding (what zero linked above).
I go here: this tool, create the curve, and load it at the beginning of the scene (with the extension) so I can use it whenever I want.
Why curved path? Because it transcends the use of other behaviors.
An object using curved path will follow the curve even if it has the platformer behavior attached, ignoring gravity, speed, forces, etc…as long as it is on the curve. Actually for flying enemies it’s easier cos usually they don’t need a platformer behaviour.
Anyway, this requires quite an advanced understanding of GD. I think it comes with time… and with lots of attempts.
Hello
However, I think it would be good if today, GDevelop had a “Path” type object.
Other engines (Game Maker, Multimedia Fusion, etc.) have had this ability for a long time.
Or integrate the RMDB solution within GDevelop if possible.
Xierra
I think this is the best way to go about it, I was actually thinking of going this route tbh, just having the x movement be constant but the y varies to give the illusion of the bell curve, I’ll try this and let you know. Thanks ![]()