Topic: Setting up a Trigger??

This email request follow a Sound trigger set up by antOn who helped me organse sounds as one passed a different space.

I have some question about setting up a Trigger.  I understand how to create a box and then make it invisible, but I cannot understand how you name it Trigger 1, Trigger 2 etc.  so that it appears in the Objects List?

Re: Setting up a Trigger??

Not quite sure what you want to understand so I will write a detailed tutorial on the triggers.

1) Download the cube model. Make the following settings:
    invisible = true
    Physics (Box) = true
    ghost = true

2) Create 3 copies of the cube (Ctrl + D). And rename them (trigger1, trigger2 and trigger3)

3)Scripting. Create a main script and open it.
- get our triggers.

--you can do this:
triggers = {getObject("trigger1"),getObject("trigger2"),getObject("trigger3")}

--But better to do it through the loop.
triggers = {}
num_triggers = 3    --the number of triggers.
for i=1,num_triggers do
    triggers[i] = getObject("trigger"..i)
--it's the same thing, if done manually:
--triggers[1] = getObject("trigger1")
--triggers[2] = getObject("trigger2")
--triggers[3] = getObject("trigger3")

Now let's write a function entry trigger.

function onEnterTrigger(trigger,entity)
    if isCollisionBetween(trigger, entity) then --if collision
        return true

Now, to verify create three cubes. Applied physics them and place them on the triggers. And create the camera.

get these cubes.

cubes = {}
num_cubes = 3
for i=1,num_cubes do
    cubes[i] = getObject("cube"..i)

Let's do that in contact with triggers, cubes disappeared.

function onSceneUpdate()
    for i=1,#triggers do
        if onEnterTrigger(triggers[i],cubes[i]) then


download project.

Re: Setting up a Trigger??

You can also interact with a single trigger.

function onSceneUpdate()
    if onEnterTrigger(triggers[1],player) then

Re: Setting up a Trigger??

Wooow!!!  antOn!!  Thank you so much for the detailed tutorial!  This helps heaps.  Many kind thanks for your efforts!!!!!!!!!!!!