|
Section 5 - Turning On The Switch When The Door Stops
Moving
Well, do you remember what I said about the Lightspot being a Switch? Yep, we're
going to need a Switcher to make the door go back to its original position. The
idea is that when the door collides with the Blocker, a switch is set. If this
switch is on and there is no object in area box, then the door will return. When
both doors collide, the switch turns off. Thus, if the switch is off and there is no object in the area
box, the door will stop. If the switch is on and there is an object in the area
box the doors
will be stopped (they might be just colliding with the blocker in this case).
If switch is off and the object is in the area box, then the door will move in
the direction of the blocker until it collides with it.
This part is easy. If the Blocker collision is true, then the Switch will be
turned on.
With that overly verbose explanation over, let's begin with the fun:
Firstly, drag-and-drop the Switch to XPresso. Add an On node and a Brightness
node
to it. The On node's function is obvious - It will be activated if the Collision is true. The
Brightness is the value we'll use as the On/Off. Now, keep in mind that the
Brightness works as a percentage - and we're working with real values. Thus 100%
= 1 and 0% = 0. Perfect for a true/false statement. There are many "Brightness" inputs in the Lightspot
object, but we are using the one in the General tab, so always use the General > Brightness input. Make sure
this is correct, as it will not work if you use the wrong one!
Now onto the juicy stuff! Firstly, connect the On value with the Blocker
Collision. This way if they
collide the node will be enabled. Then, connect the Brightness with the
Absolute
value we have created previously for the XOR Boolean node. Since you connect an
output to various inputs, there will be no problem. Just connect it's output
with the Lightspot Brightness input. You should end up with something like this:

Nothing else to see here! Moving on....
Section 6 - Breaktime
By now you can appreciate how awesomely tiresome it can be to learn a programming
pseudo-class and remain a dedicated artist. I have, therefore, decided to include this chapter,
which has the sole
purpose of getting you to relax or take a break (if you haven't had one
already). It may be a bit ridiculous, but
I've been studying psychology and this is a technique that sounded interesting to
me. It gives your brain a bit of relaxation, and can restore clearer thinking. So, have your
break time and let's move on!
Section 7 - Making The Door Return
Just to add to the confusion a little, we are now going to create a different
series of nodes. Remember the Switch? Well, we will make a script
that responds to
the "True" condition by moving the right door to the left.
So, without further ado, add the Lightspot node, and insert a Brightness output. Now, add two Right Door nodes
and a Math node. We're going to do the opposite of what we've done before.
Create a Position.X Output in the first node and a Position.X with an
On Input on
the last node. Connect this On node with the Switch Brightness.
Set the Math function to subtract and enter the same value in Input 2 that
you used in the first Math function. Connect Input 1 to the Position.X
Output of the first Right Door node, and the Output to the Position.X Input of
the second door node. You should end up with a separate little node trail
looking like this:

The door must stop when both the right and left doors collide. We can
do this by disabling the Brightness Switch. To do this, simply insert both Right and Left
Door and connect them with a Collision node. Connect the output of this
Collision node with an On input in a new Switch node, and connect an
absolute
node with value 0 with the brightness input of the Switch. This way, when they
collide, the brightness will be reduced to 0, and thus the doors will stop.
Your full, unadulterated screen in XPresso should now look like this:

Now, copy and paste all these nodes, and invert all the Right Door values to Left
Door values, Right Blocks to Left Blocks, the Maths subtract to add functions, and vice-versa,
thus cloning the code onto the left door.
And that is it - You're done! Congratulations! By learning these basics of
XPresso you will make future projects much easier to manage. If you feel
suitably enthusiastic, you should now go try new methods of getting the same
door movement. There are tons of different routes. Almost anything you can
imagine is possible here. Oh, and remember, if you have any feedback or
further questions, you can
send me an e-mail over at kaliath@-idontlikespam-uol.com.br (where -idontlikespam-
is removed). See ya!
- Tutorial written by Elentor
|