• 🏆 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!

[Trigger] [helpme] reflection unit angle

Status
Not open for further replies.
Level 9
Joined
Jun 17, 2010
Messages
217
Help me to receive a reflection angle for a leaving unit. :vw_wtf:

this trigger is poorly mapped (with another language)
  • setAngle
    • Events
    • Unit - A unit leaves Game <gen>
    • Conditions
    • Actions
    • Trigger - Turn off unitmove <gen>
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • real than or equal to 180.00
    • Then - Actions
    • Set real = (real - 90.00)
    • Else - actions
    • Set real = (real + 90.00)
    • Unit - Move (Leaving unit) instantly to ((Position of (Leaving unit)) offset by -222.00 towards real degrees)
    • Trigger - Turn on unitmove <gen>
and for collision with the units (in the trigger unitmove)
- so unit simply flying into a wall :ogre_rage:

I was going to make the game like: arkanoid for two player


below map itself :
 

Attachments

  • zzvava.w3x
    24.9 KB · Views: 35
Last edited:
Level 25
Joined
Jul 10, 2006
Messages
3,315
You need to use a component/vector movement system.

This means that you handle the X and Y (horizontal and vertical) speeds separately.

Then you make 4 regions: north east south west.

If the unit leaves north or south, you reverse its vertical motion (set y = y * -1)
If a unit leaves east or west, you reverse its horizontal motion (set x = x * -1)

BTW: Your trigger has leaks.
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 25
Joined
Jul 10, 2006
Messages
3,315

That script treats a wall as a series of circles. It's slower and less accurate than using regions, although for angled regions you need a new region system.

EDIT: So I went and changed it for you.

Here are the changes:
  • initialiZEEE
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set angle = (Random real number between 0.00 and 360.00)
      • Set speed = 15.00
      • -------- CHANGED --------
      • Set dx = (speed x (Cos(angle)))
      • Set dy = (speed x (Sin(angle)))
      • -------- ------------------ --------
      • Set u = лол2 0017 <gen>
      • Unit - Turn collision for u Off
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
  • unitmove
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set d = 0
      • -------- CHANGED --------
      • Set tempPoint1 = (Position of u)
      • Set tempPoint2 = (tempPoint1 offset by (dx, dy))
      • Unit - Move u instantly to tempPoint2
      • Custom script: call RemoveLocation(udg_tempPoint1)
      • Custom script: call RemoveLocation(udg_tempPoint2)
      • -------- ------------------ --------
      • Unit Group - Pick every unit in (Units within 200.00 of (Rally-Point of u as a point)) and do (Actions)
        • Loop - Actions
          • Set d = (d + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • d Greater than or equal to 1
        • Then - Actions
          • Unit - Move u instantly to ((Position of u) offset by -150.00 towards angle degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • angle Greater than or equal to 180.00
            • Then - Actions
              • Set angle = (angle - 90.00)
            • Else - Actions
              • Set angle = (angle + 90.00)
        • Else - Actions
  • boundHorizontal
    • Events
      • Unit - A unit enters BoundEast <gen>
      • Unit - A unit enters BoundWest <gen>
    • Conditions
    • Actions
      • Set dx = (dx x -1.00)
  • boundVertical
    • Events
      • Unit - A unit enters RedEnd <gen>
      • Unit - A unit enters BlueEnd <gen>
    • Conditions
    • Actions
      • Set dy = (dy x -1.00)
I disabled the setAngle trigger.

Your goal scoring triggers still have the same problem; take a look at my triggers so you can learn how to fix it yourself.

For the players' units that hit the ball back, I suggest you rather use regions. Use a single unit as the "base unit", and center the player's region on that unit. Then copy the "boundVertical" trigger for the bounce effect.

If you'll like to go a bit more advanced and allow positioning to determine deflection angle, you'll have to use a different method for the paddles. Get the angle between the center of the region and the ball, and set that to the ball's new angle.

This is how you set the angle:
  • Set dx = (speed x (Cos(angle)))
  • Set dy = (speed x (Sin(angle)))
Hope that made sense.
 

Attachments

  • zzvava002.w3x
    27.2 KB · Views: 36
Last edited:
Status
Not open for further replies.
Top