Let’s see. The simplest way to move in a parabola from one point to another would be to use the qarp expression. Of course you’ll need a third point as well for the middle but we can calculate that with a midpoint between the two points and move it up by some distance such as 100.
Basically give your enemy five variables: t=1, x0,y0,x1,y1
On some trigger to start the tween
— enemy: set t to 0
— enemy: set x0 to self.x
— enemy: set y0 to self.y
— enemy: set x1 to destination x
— enemy: set y1 to destination y
Enemy: t <1
— enemy: set t to min(1, self.t+dt)
— enemy: set x to qarp(self.x0, (self.x0+self.x1)/2-100, self.x1, self.t)
— enemy: set y to qarp(self.y0, (self.y0+self.y1)/2, self.y1, self.t)
Now since this is a parabola the speed will be faster at the start and end than at the middle. Making the speed constant is tricky. The simplest way is to store a list of points and treat it as a polyline. You’d do a loop to move over each line until a specified distance was moved per frame. Alternatively you could store the previous tick location and iteratively adjust t till the new calculated location from qarp is always approximately the same distance from the previous location.
There is also the math way to do it. I think the terms are function reparameterization to length. It involves calculus with integrals which I’m a bit rusty on. It could simplify to a reasonable equation though. Typically I’ve seen it approximated with the other two methods.
Or instead of a parabola you could use an arc instead. Arcs can be moved over with constant speed easily. You just need a center.
Give the enemy these variables: t=1, cx,cy, a, r
On some trigger
— enemy: set t to 0
— enemy: set cx to (self.x+destination.x)/2
— enemy: set cy to (self.y+destination.y)/2
— enemy: set a to angle(destination.x, destination.y, self.x, self.y)
— enemy: set r to distance(self.x,self.y,destination.x,destination.y)/2
Enemy: t<1
— enemy: set t to min(1, self.t+dt)
— enemy: set x to self.cx+self.r*cos(self.a+180*self.t)
— enemy: set y to self.cy+self.r*sin(self.a+180*self.t)
That will make the enemy move in a half circle arc. More subtle arcs could be possible too with further tweaks of the equations.
Also note both methods will complete the motion in one second. To make it complete in say 0.5 seconds change the *dt to *2*dt in the equations.