• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Missile - cross product or other way?

Status
Not open for further replies.
Level 5
Joined
Sep 22, 2012
Messages
90
so peepz i've been trying to imitate a missile system in which is turn rates are affected. Just like a homing missile but it somehow turns according to where the target is:

for instance on every periodic time (0.03 seconds)
if the unit is on the left side of the missile:
then add angle
if on right side
then reduce angle

attachment.php


the turning_point_domain changes periodically, units on left represented by yellow, green on right domain.

I just wanted to know if the cross product is the only way to achieve this? or is there any other way?

<@maker>
I tried making that like your trigger but it somehow turns away if my missile is fired horizontally :(
 

Attachments

  • query.JPG
    query.JPG
    10.5 KB · Views: 205
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • Untitled Trigger 001
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- -------------------------------------------------- --------
      • -------- Set unit variables --------
      • -------- -------------------------------------------------- --------
      • Set u1 = Blood Mage 0000 <gen>
      • Set u2 = Paladin 0003 <gen>
      • -------- -------------------------------------------------- --------
      • -------- Set location variables --------
      • -------- -------------------------------------------------- --------
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • -------- -------------------------------------------------- --------
      • Set r1 = (Facing of u1)
      • -------- -------------------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cos(((r1 + 45.00) - (Angle from p1 to p2)))) Greater than 0.00
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Left
          • Set r1 = (r1 + 6.00)
          • Unit - Make u1 face r1 over 0.00 seconds
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Right
          • Set r1 = (r1 - 6.00)
          • Unit - Make u1 face r1 over 0.00 seconds
      • Set p3 = (p1 offset by 15.00 towards r1 degrees)
      • -------- -------------------------------------------------- --------
      • Unit - Move u1 instantly to p3
      • -------- -------------------------------------------------- --------
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
      • Custom script: call RemoveLocation(udg_p3)
 
Level 5
Joined
Sep 22, 2012
Messages
90
<@deathismyfriend>
nearly a homing missile. WHAT i really wanted is that when i fired a bullet/missile it will

-following actions inside a timer/periodic_event
1> pick every units (unit_group)
2> check if that unit if on YELLOW SIDE THEN TURN MISSILE COUNTER-CLOCKWISE
else-if on GREEN SIDE TURN MISSILE CLOCKWISE
3> loop it until the bullet/missile hits

<P.S> I looked for some missile sys here in hive and most of them are unit oriented (100% missile hit since it loops through target unit. you can't avoid them -_-)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I still don't get it. I don't even know what's the deal with the cross effect.

If you want a Homing Missile, why Hive resources that handles that doesn't work? I have my myself a Homing Missile system some days ago. It just faces and moves faster and faster to the target, just like a Homing Missile is supposed to.

Of course that if the unit is in the left, the Missile will rotate to the left. If it's on the right, it will rotate to the right.

What i feel (taking some of what Maker did) is that you want the missile not to go toward the target in straight line, but rather be affected by movement inertia that makes it turn slower, so the missile would make some kind of spiral shape before reaching the target.

I think what maker did does your stuff.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You could also just use components.

Break up velocity into an X-component and a Y-component.
Every iteration, you simply call SetUnitX/Y, adding the X/Y components to the unit's X/Y positions. Super simple.
Now for the actual turning/speed/etc. Every iteration (or it can be a less frequent iteration), you accelerate the unit toward the target.
Set VelocityX = VelocityX + cos(angle between missile and target) * (some constant acceleration)
Set VelocityY = VelocityY + sin(angle between missile and target) * (as above)
 
Status
Not open for further replies.
Top