How to create and use triggers

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
omg_fail
Posts: 83
Joined: Wed Apr 20, 2011 1:14 pm
Location: Germany/Bavaria
Contact:

How to create and use triggers

Post by omg_fail »

Hello guys!

I wonder on how to use and create triggers in my 3D scene.So for example , if i go into a door , igot into another part of the map , or into a new map.
I read something about luna script but i am not sure about this.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: How to create and use triggers

Post by serengeor »

Scripts won't help you to create such things. You need to find a way you can get collisions between objects, in you situation trigger(plane,box,mesh,..) and some other object.
I don't think I read the same thing about luna script, because from what I read it's used for web app development..
Working on game: Marrbles (Currently stopped).
CuteAlien
Admin
Posts: 9687
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to create and use triggers

Post by CuteAlien »

You have to code a trigger-system yourself. Basically it's like serengeor mentioned - you check for collisions. So you create invisible meshes and then check for collisions between those and the objects of interest each frame.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
omg_fail
Posts: 83
Joined: Wed Apr 20, 2011 1:14 pm
Location: Germany/Bavaria
Contact:

Re: How to create and use triggers

Post by omg_fail »

Yes , using a mesh as a invisible bounding box was what I thought too.

The thing with the luna script was because I saw it in the wow folder of my friend , and it contains some coords...but nevermind.

I will see if I have the know-how to do it.

Thanks so far
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: How to create and use triggers

Post by Virion »

I just use a vector to store all triggers and use a for-loop to check collision with player every frame.
omg_fail
Posts: 83
Joined: Wed Apr 20, 2011 1:14 pm
Location: Germany/Bavaria
Contact:

Re: How to create and use triggers

Post by omg_fail »

Thats a very good idea with the vector. Thanks will try it this way
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Re: How to create and use triggers

Post by Virion »

if you want to boost performance you can try not to check collision every single frame. you can check it like every xx miliseconds so that the performance will improve slightly. the downside is, it is less accurate, not good for fast moving objects. if your object moves very slow, you can reduce the collision-check rate even further.
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Re: How to create and use triggers

Post by Iyad »

Im used to create invisible boudning boxes and detect interation to, but what I would suggest if you want tons of triggers in your map, to partition them (using a tree like structure) and then evaluate (using a for-loop) depending on your position if it is possible to interact with something in your region or subregion. This can be efficient if you have tons of npc's, destructible environment or if you simply want a full interaction with your environement.
#include <Iyad.h>
Post Reply