H/V triggers

Advanced

H/V stands for "Horizontal/Vertical"



Let me show you H/V Triggers(entity #46)





H/V triggers are special entities that create an invisible horizontal line.



Like this:

data

If the player were to pass through the line, then the H/V trigger will automatically run it's event:

data

data

If you set the "spawn with alt direction" entity flag, then it will be a vertical line:

data

Note that these lines do not stretch infinitely.


An H/V trigger is actually just a normal sized (like 16x16 or so) entity that is constantly trying to touch you. It is always moving towards you, but is locked on its horizontal or vertical axis. It's also fast, faster than the player, so it does a good job of acting as an invisible wall most of the time.


However, if the H/V trigger is placed far away enough, 2 things can happen that will limit its ability to touch you.

1) If you go past the trigger before it has time to catch up to you, you won't trigger it. The H/V trigger object is fast, but it still moves at a set speed (like half of its hitbox or something every frame). This effect is most noticable if you try to trigger an H/V trigger that is placed far away right after entering a map.

2) The H/V trigger is so far away that its AI function isn't called, and thus remains stationary. I'm not 100% sure on this, but in Cave Story entities don't seem to run their AI code if they're too far away from the player. This only seems to effect really big maps though, so the H/V trigger would have to be really really far away.


To avoid these issues, you should place the H/V triggers closer to map spawn points when possible, and or just use multiple ones spread evenly over larger areas you want them to trigger.

Previous Lesson: The hex patcher

Next Lesson: Script mode

Table of Contents