triggers, switches, levers – custom actions

Hello

Last time, I started to make my game more unpredictable. To achieve that i created my internal “script language” which is integrated into my editor and allows me to make custom actions. For now I see many uses, for example :

  • controlling moving platforms
  • opening doors
  • spawning monsters  (yep, monsters are already implemented)
  • changing music, playing suitable sounds ( mystical sound when when entering the room)

How it’s made?

Simply, first in editor I create my level, next i write formula on new script window ( yeah, it will grow to  something like UDK 🙂 ) then I can attach this formula to any object on scene like bottom of switch. After that my chosen object gains new functionality, which is executed every physics update. Especially, typical  trigger checks every update if something collide with it, than if collision occurs, it executes selected action e.g. formula like :

[sourcecode language=”cpp”]
TRIGGER REVERSE OBJ1
[/sourcecode]

mean,  if something touches the object then reverse motor of object which name is “OBJ1″. Of course OBJ1 must have joint with motor enabled, without that nothing will happen. And one more thing is needed to get it to work – object OBJ1 must exist on scene, so we must choose object and name it:

[sourcecode language=”cpp”]
NAME OBJ1
[/sourcecode]

Of course formulas can be combined to give various effects like:

[sourcecode language=”cpp”]
TRIGGER REVERSE OBJ1 REVERSE OBJ2
[/sourcecode]

reverse motor at OBJ1 and reverse motor at OBJ2. This is used in post video – opening horizontal gate
Or something like that:

[sourcecode language=”cpp”]
TRIGGER REVERSE OBJ1 DELAY 300 REVERSE OBJ1
[/sourcecode]

which can mean:  reverse motor at OBJ1 (open door) then wait 5 seconds (300 * physics fixed time-step (1/60 sec) ) then again reverse motor at OBJ1 – close the door. So player have limited time to pass through the door

Switches are made with usage benefits of bullet. Simply capsule-like shape with motor which pushes object in certain direction. Power of motor can be adjusted to the needs. If something is lying on capsule and it’s enough heavy to break power of the motor than it triggers the action. Other type of switch is made with weak motor and it triggers action twice: on collision begin and collision end. The difference of this two switches You can see on video.

Lever is a tricky part.  Every mechanics/logic work beyond eyes of player – lower part of lever  is obscured by non colliding terrain. In fact lever is composed of stick anchored in the middle and the trigger which is waiting for hit. And the only on object which is able to knock it is of course previously mentioned stick.

Especially, trigger doesn’t need to have graphical representation like switch or lever, it can be  also invisible trigger which can create situation like suddenly closed doors after entering new location and played scary sound.


 

 

 

Ps.  Success! first not jerking film!

Leave a Reply

Your email address will not be published. Required fields are marked *