Using a Collision Based Effect

Continuing on with the deconstruction of the SLENZ build this post looks at the Stairway of Learning, a set of stairs surrounding the Skill Mastery Hyperdome, the central aspect of the Foundation Studies build. It outlines the thinking behind their construction and walks through the two main scripts used to provide the interactivity.

The initial direction from the lead educator was for a set of boards that displayed information on preparing for interviews. The supplied board images highlighted each topic and each board needed to provide further information on a notecard, as well as link out to the same information on wikiEducator for offworld viewing. The fact that each board was considered a step in the preparation process gave me the inspiration to set the boards up as a set of stairs. This started to look a little busy however when all the boards were attached to the stairs, affecting the cleaner outline of the hyperdome and providing far too much visual information in one hit.

As the user group would be predominantly younger students I was keen to add game-like interactive features where possible to engage the students more directly. With this in mind I decided to add a collision based effect which would display the board to the students as they walked on each stair. As they proceed along the stairway the next board would display and the last would disappear as shown below.

Each stair is set up with the step and its rim visible and the remainder; the support, the board and the information cube; invisible (or fully transparent). In the following image I have used the keyboard shortcut Ctrl Alt T to highlight the transparent sections. The prims are linked to form a complete stair object.

There are two main scripts that activate the effect, one in the step itself called cvStepScript that runs the collision event and another in each of the transparent prims, cvSignHide (or a slight variation of this) that perform the transparency change. These two scripts are available in the linked pdfs: cvStepScript and cvSignHide


The Variable: Line 22

integer shown;

This variable is used to define the shown or hidden state.

state_entry(): Lines 26 to 29

shown = FALSE;

The state_entry event sets the value of the variable shown as FALSE, i.e. the board, its support and the info cube are hidden. It will set this value if the script is saved or reset at any stage.

collision_start(integer num_detected): Lines 31 to 39

llMessageLinked(LINK_ALL_OTHERS, 0, “show”, NULL_KEY);
llSensorRepeat(“”, “”, AGENT_BY_LEGACY_NAME, 3.0, PI, 10.0);
shown = TRUE;

The collision_start event is triggered when an avatar collides with the step. If the script was in the root prim the event would be triggered when any part of the linked group is collided with so the step itself is not set as the root prim (though it was initially for positioning purposes in the build). This means the collision only happens when the step is stepped on rather than any other part of the linked group being bumped into. In the event the IF statement, if(!shown), checks to see if shown is FALSE and if it is it runs the code block.

The first function is llMessageLinked which sends the string “show” out to all the other prims in the linked group. This is the trigger the transparent prims need to change their transparency and show themselves (see cvSignHide script). The next function, llSensorRepeat starts a repeating sensor that scans an area 3 metres in diameter from the step centre and is used to check when there is no longer an avatar within that range, i.e. no longer on the step. The last line of the block sets shown to TRUE meaning the IF statement code block wont run again until shown is changed back to FALSE.

sensor(integer numberDetected): Lines 41 to 43

This event is empty but must be present for the no_sensor event to trigger.

no_sensor(): Lines 45 to 50

llMessageLinked(LINK_ALL_OTHERS, 0, “hide”, NULL_KEY);
shown = FALSE;

This code block is triggered when the sensor no longer detects an avatar within 3 metres of the centre of the step. Its first function, llMessageLinked, sends the string “hide” out to the other prims in the linked group triggering the board, support and info cube back to full transparency. llSensorRemove then removes the repeating sensor and the last line sets shown back to FALSE, allowing the IF statement block in the collision_start event to run again the next time an avatar stands on the step.


This script handles the “show” and “hide” strings sent by the llMessageLinked function in cvStepScript. The effect triggered by receiving the “show” string is to change the transparency (in all three transparent prims). The script in the board also includes a function to alter the glow as does the script in the info cube. As well the info cube script runs a dialog to give the notecard and the wikiEducator url to the user but looking only at the basic cvSignHide is enough to understand the workings of the collision event.

state_entry(): Lines 22 to 25

llSetAlpha(0.0, ALL_SIDES);

The state_entry event ensures that the prim goes back to its transparent state if the script is saved or reset.

link_message(integer sender_num, integer num, string str, key id): Lines 27 to 37

if(str == “show”)
llSetAlpha(1.0, ALL_SIDES);
else if(str == “hide”)
llSetAlpha(0.0, ALL_SIDES);

link_message is the event triggered when the llMessageLinked function is run from cvStepScript. If the string received is “show” the llSetAlpha function sets the transparency of the prim to 0% (1.0 Alpha) and if “hide” it sets it to 100% (0.0 Alpha). Any effect could be triggered here; as mentioned above glow is part of the triggered effect for two of the prims as well; but it could just as easily be a sound, a particle effect, etc.

There are parts of the Stairway of Learning that have scripted functions other than this collision based effect but these will be looked at in an separate post. For now the above sets out how relatively simple it can be to create an effect that may engage the student beyond simply clicking objects.


3 thoughts on “Using a Collision Based Effect

  1. Pingback: Triggering Effects with llVolumeDetect « F/Xual Education Services

  2. Pingback: The Ubiquitous Teleporter « F/Xual Education Services

  3. Pingback: Scripting 101 | Multiuser Virtual Environments

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s