PACKAGE: Open Entity
Search for and install Open Entity
from the Community tab.
DESCRIPTION
Provides scripts and templates for controlling opening and closing of a single entity or multiple entities. An entity can be something like a door or a chest.
This can for example be used for opening and closing a single entity such as a normal door, or one entity that controls opening and closing multiple doors at the same time, such as as button in a prison opening all the prison cells.
It also supports having multiple entities controlling the same door, for example if you have a key card reader both on the outside and inside of a door.
Note: This package can be used in basic mode.
USAGE
Open/close a single entity by interacting with the entity itself
Add the script openEntityScript
to the entity.
When interacting with the entity, it will be toggled opened and closed.
Open/close a single entity by interacting with a controller entity
- Add the script
openEntityScript
to the controller entity, such as a button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
one time. - Select the entity you want to open under
1
.
When interacting with the controller entity, the entity selected within entitiesToOpen
will be toggled opened and closed.
Open/close multiple entities by interacting with a controller entity
- Add the script
openEntityScript
to the controller entity, such as a button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
as many times as entities you want to open. - For each of the entities you want to open, add them to the list under
entitiesToOpen
.
When interacting with the controller entity, all entities selected within entitiesToOpen
will be toggled opened and closed.
Open/close a single entity from multiple controllers
- Add the script
openEntityScript
to the first controller entity, such as a button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
one time. - Select the entity you want to open under
1
. - Add the script
openEntityScript
to the second controller entity, such as another button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
one time. - Select the same entity you want to open as before under
1
. - Add the script
openEntityCompanionScript
to the single entity you want to open/close. This is important so that both controller entities can know whether the entity is already open or not.
When interacting with any of the controller entities, the entity selected within entitiesToOpen
will be toggled opened and closed.
Open/close multiple entities from multiple controllers
- Add the script
openEntityScript
to the first controller entity, such as a button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
as many times as entities you want to open. - For each of the entities you want to open, add them to the list under
entitiesToOpen
. - Add the script
openEntityScript
to the second controller entity, such as another button. - Uncheck the
openCurrentEntity
checkbox. - Under
entitiesToOpen
, click+
the same amount of times as for the other controller. - For each of the entities you want to open, add them to the list under
entitiesToOpen
. This should be the same order as before. It is IMPORTANT that the first entity (number1
) is the same for both the controlling entities. - Add the script
openEntityCompanionScript
to THE FIRST ENTITY you want to open/close (the one that is number1
for both controllers). This is important so that both controller entities can know whether the entity is already open or not and that they check the same one.
When interacting with any of the controller entities, all the selected entities within entitiesToOpen
will be toggled opened and closed.
SETTINGS
-
isOpen
: Whether the entity or entities should start open. -
isLocked
: Whether the entity or entities should start locked. -
toggleOnInteraction
: Whether the toggle functionality should be invoked when the entity the script is attached to is interacted with. -
openCurrentEntity
: Whether the current entity is the one that should be controlled, such as when attaching the script directly to a door or chest. -
entitiesToOpen
: IfopenCurrentEntity
is false, you must specify an array of which entities to control, such as all cell doors in a prison being opened from a single button.
Note: If you are using a companion script, the isOpen
and isLocked
settings must be set on the openEntityCompanionScript
instead of the openEntityScript
. This is to ensure that the state of whether the entity/entities are open and unlocked must be shared between all controllers.
ADVANCED USAGE
Instead of using the OnInteract
event for toggling an entity open/closed, you can instead attach the openEntityScript
to something else, such as a Locator. You can then use the script API to manually invoke the methods listed below.
METHODS
-
Toggle
: Toggles the entity as open or closed, based on the current state. -
Open
: Opens the entity (or entities). It is disallowed to open an entity while it is locked. -
Close
: Closes the entity (or entities). It is allowed to close an entity while it is locked. -
Lock
: Locks the entity (or entities). -
Unlock
: Unlocks the entity (or entities). -
IsOpen
: Returns whether the entity (or entities) is currently open. -
IsLocked
: Returns whether the entity (or entities) is currently locked.
EVENTS
-
onEntityOpened
: Fired when the entity (or entities) is opened. -
onEntityClosed
: Fired when the entity (or entities) is closed. -
onEntityUnlocked
: Fired when the entity (or entities) is unlocked. -
onEntityLocked
: Fired when the entity (or entities) is locked. -
onEntityOpenAttempt
: Fired when an attempt to open the entity (or entities) fails because the entity (or entities) is currently locked.
Note: No events are fired during inititalization.
EXAMPLE TEMPLATES
This package comes with a few example templates to show how to use it.
-
SingleOpenEntity
: A single door with theopenEntityScript
attached. You can change the door mesh and other settings to make it fit your game. -
MultiOpenEntity
: Two doors and a controller. The controller has theopenEntityScript
attached, and the first door has theopenEntityCompanionScript
attached. This means that initial state is controlled from theopenEntityCompanionScript
forisOpen
andisLocked
. It also enables you to have multiple controllers in case you want to control the set of doors from several places, such as on the outside and inside.