Ok, sorry, I've been too brief above.
Let's break it into steps:
(I'm not sure what you mean by segment of an arc. Do you want the segment to initiate some action when it is touched, shot, clicked, ...?)
Let's just assume that the segment is a solid piece of wall or floor and you want an action to occur when someone walks near it.
You would create a new brush next to the segment, assign the "Trigger" material to it and move and shape it so that it encloses the
volume that later should, when touched, trigger the action. That is, players are supposed to walk "into" this newly created brush (this is why it is rendered invisible in some of the CaWE render modes). It is the "Trigger" material that causes it to attain that special behavior. Such a brush is called a "trigger volume".
Next, when the player walks into such a trigger volume, what happens?
Note that trigger volume brushes are supposed to be part of a dedicated entity that has a Script component.
That is, the minimal setup is an entity that contains a trigger volume and a Script component. At this point, nothing else is needed.
Whenever something walks into the trigger volume, the script's
OnTrigger()
method is called.
That is, the Script component must either point to a script file that defines this method, or you can enter the code into the ScriptCode field directly. For example:
Code: Select all
local Trigger = ...
function Trigger:OnTrigger(Other)
-- Add your code here.
-- Here is typically a call to the door or lift
-- that tells it to run it's action (open/close/move/...).
end
(Well, I know, this may seem cumbersome, but it actually provides a huge deal of flexibility!)
Ohh, it just comes to mind: Make sure to check out the two trigger volumes in TestPatches.cmap! These provide really good examples of the technique described so far!
Next, the door or lift (that is for now an entirely different entity from the above) must be addressed as mentioned in the above code comment. For example:
Code: Select all
local Trigger = ...
function Trigger:OnTrigger(Other)
-- For more detail about this, see Games/DeathMatch/GUIs/Activate_main.cgui
local DoorEnt = world:GetRootEntity():FindByName("my_door")
local DoorScript = DoorEnt:GetComponent("Script")
DoorScript:OnActivate(Other)
end
The doors in turn are well implemented as entities with Mover components that help with collision detection and generally implement the move. See the comment at the top of Scripts/MoverBinary.lua for additional details.
Finally, note the trick that we use with the doors that you see in map Kidney (and elsewhere): The entity that keeps the trigger volume and the entity that keeps the Mover component are just one, which in turn simplifies the script setup, because you only need one script file, not two. It is a consequence of this two-in-one setup that the script in Scripts/MoverBinary.lua contains this code:
Code: Select all
function Script:OnTrigger(OtherEnt)
self:OnActivate(OtherEnt)
end
which establishes the connection between the trigger volume and the Mover.