Making a door open only if you are carrying a cube
Quote from slakkie on February 6, 2008, 10:21 pmHi all,
I have just started making Portal maps. Whupper, also active in this forum, inspired me. I am having alot of fun.
I have a map where the objective is to bring the cube with you and I wanted to make a door that opened if, and only if, you had the cube in your possession (holding it, really).
What I came up with was very simple and I thought I'd share the find with the forum in case someone else wants to do the same thing.Instructions:
- Fashion a door of some type: func_door as parent and all that.
- Make a trigger brush
- Set an OnTouch output to an "Open" action to the door
- Check the Everything option on the Flags page so the cube will set off the trigger
- Make a filter_multi and name it. "EndDoorFilterBox" in my case
- Make a filter_activator_name and name it "Filter_Player"
- Set "Filter Mode" to Disallow
- Set Filter Name to "!player" (without the double quotes)
- Make another filter_activator_name and name it Filter_box
- Set "Filter Mode" to Allow
- Set "filter Name" to the name of the box you have in the map.
- Back at the filter_multi
- Set "Negate outcome" to "no"
- Set "Logic Type" to "AND"
- Set "Filter 1" to "Filter_Player"
- Set "Filter 2" to "Filter_box"
- Set the "Filter" attribute of the trigger to the name of the filter_multi
(None of the values should actually use the double quotes. I use them just to make it easier to read)
The result is that the trigger will only be triggered if you are holding the cube in your hand (with "e") while walking thru it. The door will remain closed if you aren't holding the cube.
Regards
--Slakkie
Hi all,
I have just started making Portal maps. Whupper, also active in this forum, inspired me. I am having alot of fun.
I have a map where the objective is to bring the cube with you and I wanted to make a door that opened if, and only if, you had the cube in your possession (holding it, really).
What I came up with was very simple and I thought I'd share the find with the forum in case someone else wants to do the same thing.
Instructions:
- Fashion a door of some type: func_door as parent and all that.
- Make a trigger brush
- Set an OnTouch output to an "Open" action to the door
- Check the Everything option on the Flags page so the cube will set off the trigger
- Make a filter_multi and name it. "EndDoorFilterBox" in my case
- Make a filter_activator_name and name it "Filter_Player"
- Set "Filter Mode" to Disallow
- Set Filter Name to "!player" (without the double quotes)
- Make another filter_activator_name and name it Filter_box
- Set "Filter Mode" to Allow
- Set "filter Name" to the name of the box you have in the map.
- Back at the filter_multi
- Set "Negate outcome" to "no"
- Set "Logic Type" to "AND"
- Set "Filter 1" to "Filter_Player"
- Set "Filter 2" to "Filter_box"
- Set the "Filter" attribute of the trigger to the name of the filter_multi
(None of the values should actually use the double quotes. I use them just to make it easier to read)
The result is that the trigger will only be triggered if you are holding the cube in your hand (with "e") while walking thru it. The door will remain closed if you aren't holding the cube.
Regards
--Slakkie
Quote from slakkie on February 6, 2008, 11:12 pmWhen I played thru the map I realized that I need to display a message to the player if he/she tries to open the door without the cube in hand.
The way I achieved that was with a second trigger, located just behind the first (both just a few pixels wide), that send a "test" output to a logic_branch that was set to 1 (true) by the trigger mentioned in my last post if the user has the cube. Per default it is set to 0 (false)
When receiving a Test input the logic_branch outputs a trigger to a logic_relay that actually opens the door if it (the logic_branch) is set to 1 or outputs a "display" to a game_text entity if 0.
- Create a logic_branch
- Create a game_text entity.
- Set its "Message Text" to "Bring the cube" or some such.
- Create a new trigger_multiple just behind the first trigger so that the player will trigger it just after he triggers the discriminating trigger described in my first post.
- Set an output to issue a "test" to the logic_branch
- Set the first trigger_multiple to output a "SetValue" with parameter of 1 to the logic_branch.
- Set the logic_branch to output "display" to the game_text OnFalse and a trigger to the logic_relay to open the door OnTrue
This works really well. The message appears again when the player backs away but that is probably a good thing. It does not appear when he/she comes back with the cube. Instead the door is opened!!
Regards
Slakkie
When I played thru the map I realized that I need to display a message to the player if he/she tries to open the door without the cube in hand.
The way I achieved that was with a second trigger, located just behind the first (both just a few pixels wide), that send a "test" output to a logic_branch that was set to 1 (true) by the trigger mentioned in my last post if the user has the cube. Per default it is set to 0 (false)
When receiving a Test input the logic_branch outputs a trigger to a logic_relay that actually opens the door if it (the logic_branch) is set to 1 or outputs a "display" to a game_text entity if 0.
- Create a logic_branch
- Create a game_text entity.
- Set its "Message Text" to "Bring the cube" or some such.
- Create a new trigger_multiple just behind the first trigger so that the player will trigger it just after he triggers the discriminating trigger described in my first post.
- Set an output to issue a "test" to the logic_branch
- Set the first trigger_multiple to output a "SetValue" with parameter of 1 to the logic_branch.
- Set the logic_branch to output "display" to the game_text OnFalse and a trigger to the logic_relay to open the door OnTrue
This works really well. The message appears again when the player backs away but that is probably a good thing. It does not appear when he/she comes back with the cube. Instead the door is opened!!
Regards
Slakkie
Quote from Ricotez on February 7, 2008, 10:34 amFunny, this is not an I-have-a-question-topic but an I-have-an-answer-topic! You should create an article about this on the TWP Wiki, I'm sure there are other people who want to know this!
Funny, this is not an I-have-a-question-topic but an I-have-an-answer-topic! You should create an article about this on the TWP Wiki, I'm sure there are other people who want to know this!
"Duct Tape is the answer."
Quote from xitooner on February 7, 2008, 11:49 amslakkie wrote:The message appears again when the player back away but that is probably a good thing.Sounds like your trigger is very thin, so the user (or cube) goes through it entirely on the way to the door.
Instead, make it a much larger trigger (more of a box instead of a wall) that fills up the area in front of the door. . . so the player walks into the trigger and stays inside its area if he is in front of the door.. Then assign the trigger for the message to OnStartTouch, or something. That way, the message is given every time he leaves the area and approaches the door, instead of when he is both coming and going.
Sounds like your trigger is very thin, so the user (or cube) goes through it entirely on the way to the door.
Instead, make it a much larger trigger (more of a box instead of a wall) that fills up the area in front of the door. . . so the player walks into the trigger and stays inside its area if he is in front of the door.. Then assign the trigger for the message to OnStartTouch, or something. That way, the message is given every time he leaves the area and approaches the door, instead of when he is both coming and going.