Thursday, February 23, 2012

On Placement, Size, and Shape of LightingBalls and LightingBallControllers



LightingBalls: NO.  Size does not matter at all.  While LightingBalls are technically a trigger, their script does not have either an OnTriggerEnter or OnTriggerLeave Event.  So, the bounds on the primitive shape is purely aesthetic.  Make them as small or large as you want them to be.

LightingBallControllers: YES.  Size does matter for all three dimensions.
A typical LightingBallController.  You can imagine its balls placed in front and behind it.
Height:  I would not use anything less than 196 for height, which should pretty much always be on the z-axis, because a player can jump over one that is only 128 units high.  I believe 196 is pretty safe to use.

Width: I consider 64 to be generally safe for width.  The lower you go, the more aggressive the controller becomes.  So, in short corridors, you may feel its necessary to use a shorter width in order to make sure a light comes on before the player can see it happen.  With this potential payoff comes greater risk, however, as I will explain in great detail...
A top-view of the Playerball 1, and ball 2 forming a triangle with sides a, b, c; where ball 1 is always the closest ball to the player.  

Just after the player leaves the controller's boundary (moving from yellow to black), the controller's OnTriggerLeave Event fires and the calculations to determine which side the player is on begins -- the lengths of b and c are reported to the controller, which then compares the two.

After determining b is the shortest length,  ball 2's lights are disabled, while ball 1's lights are enabled.  However, some time does pass between the firing of the OnTriggerLeave Event and the actual enabling/disabling of lights.

Exactly how much time passes between these two events is not set in stone, and is not affected by the lengths of a, b, or c -- only by the amount of other things competing for processing time at that moment.  During this period of time, the player is still free to move about and do unanticipated things.   The width of the controller is the buffer zone where the players movement does not matter.

The Horizon Line (Yes, I totally made that up) is where b = c.  Thankfully, in this ideal setup, it is fairly deep within the controller.  As you shrink the width, the buffer zone between the horizon line and the controller's boundaries also shrinks -- but the position of the Horizon Line would not change.

Length:  Typically, the length of the controller needs to be long enough to completely cover all possible paths the player may take.  Whether its a narrow corridor, across an entire room,  or across half the cell... it doesn't matter.  It'll still work, because no matter how long b gets, it will always be significantly shorter than c.

 Placement

LightingBalls: YES.  Ball placement determines where the Horizon line actually is.



Here is an example of badly lopsided (hung?) balls.

Because line a does not form a right angle with the controller's boundaries, the Horizon Line is completely messed up (technical term).

This controller will not function as expected.  Or, more precisely:

There are very few paths that the player can take where the controller will function properly.

If the player runs from the top to the bottom, s/he would have to exit at a yellow section of the controller.  Conversely, if the player runs the other way, s/he would have to exit at a gold section of the controller. Otherwise, the wrong set of lights will go on/off.

For the Player's Path in the above image, c will always less than b.  Therefore, ball 2 will always be closest, and so the lights rigged to ball 1 will always be off.  And since you probably never bothered to test your mod before uploading it, people will complain about how buggy your mod is.  You'll end up blaming me, your mom, and your dog.

To fix it, you'd need to move either ball 1 or ball 2 to the left or right (respectively) so that line a is completely vertical in this image.  Alternatively, you could rotate the controller so that the horizon line is both parallel and bisects it.


You may be saying, "OK, Captain Obvious.  I understood Pythagoras's Theorum since I was like 8 months old."

Well, there are implications which you may not have considered, which I'll talk about later in an advanced tutorial just for you.

LightingBallControllers:  YES.  Placement  does matter.

Shape

LightingBalls: NO.  Shape does not matter at all.
LightingBallControllers: YES.  Shape does matter.

<I'll finish this later>

Go back to main tutorial page

No comments:

Post a Comment