It uses four variables, which I called time, speed, deltax and deltay. You can change the speed of the missile by changing the value of the variable "speed", be sure however to set it to anything but zero, or else it'll induce a runtime error.
To use this script:
1- In the .txt file of the NPC you wanna use as the projectile, add the following line:
scripts=chase
2- In the Script editor, create a script called "chase", and paste the following code in it:
Code: Select all
with npc(sysval(param1))
'Sets the Δy value
val(deltay)=(Char(1).Y-.Y)
'Sets the Δx value
val(deltax)=(Char(1).X-.X)
'Sets the Δt value
val(time)=(sqr(val(deltax)^2+val(deltay)^2))/val(speed)
'Sets the vertical and horizontal speed values
.Ysp=val(deltay)/val(time)
.Xsp=val(deltax)/val(time)
end with
3- Create four variables, called "time", "speed", "deltax" and "deltay"
4- Set the "speed" variable to the speed you want for the projectile. Do NOT leave it at zero!
5- And then place your projectile.
That's all. I've included a test level:


