Page 1 of 1

Question and help: Moving Projectile in terms of Speed and Angle (cos and sin)

Posted: 26 Mar 2020, 18:43
by HumanReploidJP
So I've seen the rotating flamethrower since 1.4.1 until it's not included in 1.4.5. That got me thinking if I want to make a projectile that moves at a constant speed and angle.

Spoiler
15852375222998134759906682818726.jpg
This is the concept of cos and sin angle and constant speed. I'm waiting for results based.

I've seen the logic about the sin and cos, in terms of degree angle. So technically like the bouncing podoboo, or the projectile that was shot from a magikoopa from SMW.

So, I would need some help for your coding example, if you must. Let me know,and respond to this reply :to_keep_order: . Thank you.

Posted: 6 May 2020, 3:57
by Monad
You can do it by very simple trigonometry

Code: Select all

dim angle as double
dim speed as double

with npc(sysval(param1))
   .xsp = cos(angle) * speed
   .ysp = -sin(angle) * speed


That way you can control an NPC not by two coordinates (cartesian plane) but by its angle and speed, which are respectively equivalent the angle and distance from the center in a polar coordinate system.