# [Trigger]Bounce Angle Formula

#### lnfernal

Level 8
Okey. I tried with this formula but didn't work. I'm trying to make a bounce angle.

• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Facing of Unit1[(Integer A)]) Greater than or equal to 180.00
• Then - Actions
• Set RM_Angle[(Integer A)] = (540.00 - (Facing of Unit1[(Integer A)]))
• Else - Actions
• Set RM_Angle[(Integer A)] = (360.00 - (Facing of Unit1[(Integer A)]))

This trigger works great. Except in some cases, it can't check if the wall is either south or north, west or right. Example with this code, let's say the red line is 45 degrees, which means it's reflection should be 315 degrees. And in this case it works great.

But when I use this formula and try to bounce to the south direction, it went like this.

The red line is still 45 degrees, but this time it also reflect 315 degrees, right in the wall, the black line. But it should have bounced 135 degrees, the white line. I can solve this by doing 180-Facing of unit, then the south wall will work, but then the right wall will be messed up. So I need to find a way to somehow check where I hit.

Level 12
1stly, you shouldn't be doing this with angles but rather X,Y that way all you have to do is set one of them to: Itself x -1

#### lnfernal

Level 8
Don't know how to use x/y. Is that the only way and will it work? Can I post the code and ask for someone to do that? That's JASS right?

#### PurplePoot

Level 40
~Moved to Triggers & Scripts.

#### WildField

Level 3
360 - facing(for east/west) , 180 - facing (for north/south)

#### lnfernal

Level 8
That's what I'm doing right now.. Read the problem.

If you shoot a ball at 45 degrees, it can either bounce 315 degrees OR 135 degrees depending which side you throw it of the wall.. My formula only support 315 degrees. And I can't seem to find a way to make it support both 135 and 315 degrees depending where the wall is.

Level 17

#### lnfernal

Level 8
I've read the whole thread. And their solution seem to be 180-a. Isn't that what my trigger is?

#### PurplePoot

Level 40
If you take that approach, it's 180-a relative to the surface, and the relative to the surface bit is exactly the problem you're having right now.

I've never really done any stuff with physics, but I'll see if I can come up with something.

#### lnfernal

Level 8
Don't worry. Someone found a way. But he said it may bug so he didn't realease it as a tutorial (Didn't say what bug).

#### GhostWolf

Level 29
You simply put the negative value of the angle, or you do what Poot said.
Both of them don't work for 2 angles:
-a - 0 and 180
180-a - 90 and 270
So, whichever you use, remember to check first if it is not one of the angles that don't work.

Replies
0
Views
385
Replies
21
Views
801
[Trigger] Ball Bounce
Replies
26
Views
2K
Replies
7
Views
906
Replies
3
Views
439