• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Returning Projectile Formula

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
Hi. I need help with a formula for a periodic trigger that are supposed to move 2 Dummy units like in the picture below.

The caster throws two projectiles that flies outwards in a straing line that turns outward and returns to the caster in a slighlt diagonal way. Hope I explained clearly enough.

180023-albums7569-picture91946.jpg
 
5.45 degrees per 0.03 seconds will make a semi-circle out of it.

The path doesn't seem to be semi circle though. So it would probably be about 10.91 degrees per 0.03, with -0.5 acceleration. In over a second its angle would be straightened.

You can play around with the acceleration (not positive though).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,205
If you process it enough you would probably find some formula involving the composition of 30 sin/cos calls that works. However in this case I would recommend breaking it into three parts.

1. Go straight.
2. Go in a circle until facing the caster.
3. Go straight to caster (tracking so if he moves it follows).
 
Level 12
Joined
Oct 16, 2010
Messages
680
the straight parts wouldn't be a problem so lets focus on the "turning"

once the missiles reaches the target start changeing the angles of the projectiles by ("+"for the left missile and "-"for the right)
+- 10,8°/period ( like this it will turn 360° under 1 sec with 0.03 period) and move forward the missile
chech every period the angle toward the caster and if (angle toward caster)-(missile face angle)<=5,4 then start phase 3
 
chech every period the angle toward the caster and if (angle toward caster)-(missile face angle)<=5,4 then start phase 3
After subtraction check if negative or above 180. For the first, turn positive (for GUI multiply by 2 and add), and for the second subtract 180.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,205
After subtraction check if negative or above 180. For the first, turn positive (for GUI multiply by 2 and add), and for the second subtract 180.
Or more easily you rotate the projectile and check if the difference in angle of facing and the caster direction is inside a certain range using cosine. This saves all the buggy conditional checks.

After that stage you move it towards the caster by a certain amount. Unless the caster abuses long distance teleports it will eventually have to return to him if it has a speed larger than the max movement speed. Just to prevent abuse (in case a cross map teleporter is used so that units inbetween are not hurt) you should turn off all damage mechanics after it has travelled some multiple of the cast range returning to the unit.
 
Status
Not open for further replies.
Top