LordMargatroid wrote:
See? enemies formation... but I don't know how to make it..
Okay, so I guess your trying to make dudes that curve around on their flight path like that? There are several ways of doing it.
First off, I hate GML's in-built pathing thingy. It gave me inconsistent results. I prefer to work with everything in script anyway. Maybe others can give advice or tutorial on paths. Might be better then the shit I'm about to ramble about:
Script wise, the two most basic ways to make an elaborate curving path are to either rotate the direction of movement over time, or use a sine wave.
For example, in directions, you could do something like:
Code: Select all
direction += (curve * curveDirection)
timer -= 1
if (timer < 1)
{
curveDirection *= -1
timer = 60
}
direction is movement direction obviously.
Curve is the amount we change the movement direction by every frame
CurveDirection is either 1 or -1.
Timer is counted down every frame.
When timer hits 0, its set back to its initial value and curveDirection is multiplied by -1 to change its positive/negative value and thus change the direction the enemy moves in.
This is just an example. It's annoying and a lot of work to work with directions + timers, but it can work if you can't think of a better way.
Another cleaner alternative is to work with sine waves.
For example you can get the classic "wavy" path by doing
Code: Select all
sineIncrement += 1
x += sin(sineIncrement )
you can change the amount the sineIncrement is increased by each frame, add a multiplier to the sine, etc. in order to change the size/shape/speed of the wave. This is *really* good for simple stuff.
Lastly, another method that immediately comes to mind for complex paths is to create a "turn to angle" function, that will turn the direction of the object to a specific direction by a certain amount each frame, and then choose points to steer it towards along its path. IE
Code: Select all
aim = direction towards point1
scr_turntoangle(aim,TurnSpeed)
if (distance to point1 < 10)
{
point1 = nextPoint
}
^^^What we're doing here in rough pseudocode form is choosing a point, aiming our direction towards it each frame, and then changing to the next point when we get close enough.
If you're a top tier math/programmer brain you could probably do something with splines or some shit too, maybe make your own version of GML's path system. But I wouldn't recommend that to a beginner.
Honestly this is something of an artform and something you'll have to play around with and experiment on your own as you go. There are lots of different ways of scripting different kinds of movement. Some better, some worse. Some more efficient, some less efficient. As a game developer you tend to learn something new every day. So good luck!