|
Section 4 - Making Doors Stop When They Hit The Blocker Object
The Logic behind this step is actually in reverse - The doors won't "stop" when they hit the
Blocker, they just move when they are NOT hitting the blocker. I know it sounds
confusing, but you will understand it soon enough...
The first thing we need to do is create the collision between the right door and the blocker
object. So, insert both objects' nodes and a collision node and connect them just
like the first. You should get something like this:

Now things are starting to get serious - How are we going to make the door stop
moving when it is colliding with the blocker? The answer is simple - we'll use Boolean
functions! A Boolean function is one that plays with
True and False values. We will configure the scene so that when the Area-Object Collision is True and Door-Blocker is False, the door moves, and if Area-Object is True and Door-Blocker True too, the door won't move. If Area-Object collision is false, independently of the Door-Blocker, the door won't
move either.
Of course, we could just add a Dynamics module into the scene and be lazy, but
what would be the fun of it? It is also unfortunate that this little cheat would make
our scene MUCH slower to render!
Our boolean functions should IDEALLY look like this:
|
Area Box Collision |
Blocker Collision |
Movement |
| 1 (TRUE) |
1 (TRUE) |
0 (FALSE) |
| 1 (TRUE) |
0 (FALSE) |
1 (TRUE) |
| 0 (FALSE) |
1 (TRUE) |
0 (FALSE) |
| 0 (FALSE) |
0 (FALSE) |
0 (FALSE) |
If this were possible, movement would only occur if Input 1 is 1 and Input 2 is 0. Unfortunately such
Boolean functionality does not exist. But what if we 'invert' the Blocker
Collision values? The table would then look like this:
|
Area Box Collision |
Blocker Collision |
Movement |
| 1 (TRUE) |
0 (FALSE) |
0 (FALSE) |
| 1 (TRUE) |
1 (TRUE) |
1 (TRUE) |
| 0 (FALSE) |
0 (FALSE) |
0 (FALSE) |
| 0 (FALSE) |
1 (TRUE) |
0 (FALSE) |
As you can see, this function would only work if both collision values are true
(i.e. 1). Such a function
exists - It's the Boolean AND function.
But how can we make Blocker Collision's values change? There are two ways
actually, but for now, we will be using another Boolean function, XOR. XOR
means "Exclusive OR". To understand XOR, you need to understand OR. The OR
function results a true if at least one of the inputs are true. The XOR
results true if ONLY ONE of the inputs are true - If both are true then it
will result false. Such a big meanie!
OR Table:
|
Area Box Collision |
Blocker Collision |
Movement |
| 1 (TRUE) |
1 (TRUE) |
1 (TRUE) |
| 1 (TRUE) |
0 (FALSE) |
1 (TRUE) |
| 0 (FALSE) |
1 (TRUE) |
1 (TRUE) |
| 0 (FALSE) |
0 (FALSE) |
0 (FALSE) |
XOR Table:
|
Area Box Collision |
Blocker Collision |
Movement |
| 1 (TRUE) |
1 (TRUE) |
0 (FALSE) |
| 1 (TRUE) |
0 (FALSE) |
1 (TRUE) |
| 0 (FALSE) |
1 (TRUE) |
1 (TRUE) |
| 0 (FALSE) |
0 (FALSE) |
0 (FALSE) |
If we add a Boolean XOR between the Blocker Collision and a "1" value,
we will effectively invert the value. i.e. 1 (TRUE) will become 0 (FALSE)
and vice versa. The Final Result would be:
|
Blocker Result |
Area Box |
Result |
| 1 (TRUE) |
1 (TRUE) |
1 (TRUE) |
| 0 (FALSE) |
1 (TRUE) |
0 (FALSE) |
| 1 (TRUE) |
0 (FALSE) |
0 (FALSE) |
| 0 (FALSE) |
0 (FALSE) |
0 (FALSE) |
Since the last node On value is only enabled by a True condition, the only true
condition of this situation would be with the Blocker Collision off and the Area
Box Collision on, which is what we need! If the Area Collision ceases, the
movement will stop, and if the Blocker collision happens, the movement will also
stop.
Still keeping up? Finding this a little confusing? If case your brain is getting hot,
try
some C.O.F.F.E.E.! Yeah that was a nasty, evil joke. Sorry. ;)
Now back to the tutorial. Right click the window and select New Node > XPresso >
Bool > Bool. Create two Booleans, as one will be the XOR and the other will be
AND. Connect the XOR first input with the Blocker Collision node output. Now
connect the AND first node with the Area Box Collision, and the second with the XOR boolean output. Connect it's output with the last Right Door Node On Input.
Now, you will need to create a value to XOR with the Blocker Collision. Right
click and select New Node > XPresso > Calculate > Absolute. Leave it's input alone and
connect the Output with the XOR Boolean's second input.
Now on the attribute window. Click on the Absolute node and set it's value to
1, as it will input to the XOR as a true value. Click the XOR Boolean and, in the Node tab,
choose XOR as a function (naturally). Do the same for the AND Boolean, but
selecting the AND Value (obviously). All your hard work and patience with this
section should have left you with an XPresso screen like this:

We're done here (finally). The next part won't be so hard, I promise!
;)
- Tutorial written by Elentor
|