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)
end
--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
end
end
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)
end
Let's do that in contact with triggers, cubes disappeared.
function onSceneUpdate()
for i=1,#triggers do
if onEnterTrigger(triggers[i],cubes[i]) then
deactivate(cubes[i])
end
end
end
Result:
download project.