Simple Bouncing

Paladin

New Member
Reaction score
8
I know how to make a trigger so that when a ball hits a wall, it bounces off at the same angle it came in, like this picture. It is very simple as you can see. However, how do I make a system like this where the "ball" isn't already placed and there are many units ( Walls ) that it can bounce off of? :confused:

Thanks :)
Paladin


No one is helping *Boo-Hoo*
+Rep to anyone who gets me closer to helping me solve this problem!
 

Attachments

  • EXAMPLE.bmp
    48.1 KB · Views: 167

Paladin

New Member
Reaction score
8
See, this is the problem I am having: people aren't understanding me...

Say you have a bouncy-ball; lay it flat on the ground, and hit it against a wall ( you are not throwing it, just rolling it to the wall ). It comes out at the same angle that it came in from... In WE I need to find out how to do this BUT if the "ball" is not placed in WE and if there are more than say, 1,000 units that it can bounce off of... I know it might seem hard to understand but I'm not asking for a comlicated physics system. :p

P.S. The first example would be a 2D, flat surface.

__________________________________________
---------------------/\-------------------------
--------------------/--\------------------------
-------------------/----\-----------------------
------------------/------\----------------------
-----------------O-------\----------------------


In the diagram above, the parentheses is the path that the ball travels and the ball is of course the O. THE WALL IS THE TOPMOST LINE!
 

Cheddar

This is the way it was meant to be.
Reaction score
126
I cannot fully give you the trigger, but I can offer some hints:

Moving the ball is simple, but I think I would make it based on the ball's facing angle, it makes the bouncing a bit easier.

There are a few ways to trigger the ball bouncing; two of which I think are:
~If the terrain is a certain type at the position of your "bouncer" (The terrain type at the cliffs of which it bounces off), then change it.
~If you move your ball a distance of, say, 5.00 every time the trigger went off, then check if the distance between its old and new position is less than 5.00 (If a unit is being knocked back into something it cannot penetrate, you will notice it constantly moves back and forth) then you know it has hit a wall of some sort, so change its facing angle.

I think the second detection is a bit simpler, but...
 

Paladin

New Member
Reaction score
8
I cannot fully give you the trigger, but I can offer some hints:

Moving the ball is simple, but I think I would make it based on the ball's facing angle, it makes the bouncing a bit easier.

There are a few ways to trigger the ball bouncing; two of which I think are:
~If the terrain is a certain type at the position of your "bouncer" (The terrain type at the cliffs of which it bounces off), then change it.
~If you move your ball a distance of, say, 5.00 every time the trigger went off, then check if the distance between its old and new position is less than 5.00 (If a unit is being knocked back into something it cannot penetrate, you will notice it constantly moves back and forth) then you know it has hit a wall of some sort, so change its facing angle.

I think the second detection is a bit simpler, but...

OK good... Except that the units that it bounces off of are units that are walls. Also, the "ball" has to move very fast yet it cannot give too much lag because the game will be for two to three players.
 

Cheddar

This is the way it was meant to be.
Reaction score
126
Okay, if you are extremely patient you could make regions at the places on the walls where it should bounce, then do:

Code:
Events: Unit enters Bounce Region 1
Conditions: Unit-type of (Entering unit) equal to Bouncer
Actions: Set Facing angle of (Entering unit) to (Facing angle of (Entering unit)) + (Random number between (-40 and 40))

That way its facing angle will not constantly change, but experiment with the numbers to find an amount that will always have it bouncing.
 

Paladin

New Member
Reaction score
8
Wow, I am a little stupid that I had not thought of that before! :banghead:

Thanks
Paladin
 

Evoroth

New Member
Reaction score
11
Okay, if you are extremely patient you could make regions at the places on the walls where it should bounce, then do:

Code:
Events: Unit enters Bounce Region 1
Conditions: Unit-type of (Entering unit) equal to Bouncer
Actions: Set Facing angle of (Entering unit) to (Facing angle of (Entering unit)) + (Random number between (-40 and 40))

That way its facing angle will not constantly change, but experiment with the numbers to find an amount that will always have it bouncing.

But then it doesn't jump properly... It should be possible to invert the unit's facing via the x axis if it hits a horizontal wall, and the y axis if it hits a vertical wall. I will give you the code tomorrow (I hope), I got to sleep :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top