Gameplay / BlockingVolume
BlockingVolume Class
Blocking area
It is used to control whether the character can enter and exit this area.
Precautions
Each end of the object is generate, and the traffic license is sync from the server to the client
Usage example: create a script named "BlockingVolExample", place it in the object bar, open the script, enter the following code, replace the GUID, save it, and run the game. You will be able to use the blocking area corresponding to the GUID. The code is as follows:
@Component
export default class BlockingVolExample extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected async onStart(): Promise<void> {
// Get the current Player
let player = await mw.Player.asyncGetLocalPlayer();
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
mw.InputUtil.onKeyDown(Keys.F1,()=>{
// F1 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
// Player character Add Access Permit
blockingVolume.addPassableTarget(player.character);
})
}
}
}
@Component
export default class BlockingVolExample extends Script {
// When the script is instantiated, this function will be called before the first frame update
protected async onStart(): Promise<void> {
// Get the current Player
let player = await mw.Player.asyncGetLocalPlayer();
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
mw.InputUtil.onKeyDown(Keys.F1,()=>{
// F1 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
// Player character Add Access Permit
blockingVolume.addPassableTarget(player.character);
})
}
}
}
Hierarchy
↳
BlockingVolume
Table of contents
Properties
click
Properties
onBeforeDestroyDelegate: MulticastDelegate <() => void > other |
---|
Event callback before object destruction |
onCustomPropertyChange: Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> other |
Monitor custom attribute synchronization events |
onDestroyDelegate: MulticastDelegate <() => void > other |
Event callback after object destruction |
onPropertyChange: Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> |
Monitor system replicated events |
Accessors
click
Accessors
actorFlagValue(): number other |
---|
Get object tags |
actorLevel(): number other |
Obtain Actor Level |
assetId(): string other |
Retrieve the UID of the resource currently being used by the object |
gameObjectId(): string other |
Get the unique identification of an object (a string that uniquely identifies an object). |
isDestroyed(): boolean other |
Has the current object been destroyed |
isReady(): boolean other |
Current object status |
localTransform(): Transform other |
Local transformation of the current object |
name(): string other |
Return the current object name |
netStatus(): NetStatus other |
Get the current object synchronization status |
parent(): GameObject other |
Retrieve the current parent object |
tag(): string other |
Get the tag of the current object |
worldTransform(): Transform other |
Current object world transformation |
Methods
addPassableTarget(target : GameObject ): void other |
---|
Add permissions to the target through this area |
clear(): void other |
Reset the blocking area |
getTargetPassable(target : GameObject ): boolean other |
Get permission for target to pass this area |
removePassableTarget(target : GameObject ): void other |
Remove target's permission to pass this area |
unblockAll(): void other |
Open blocking area |
click
Methods
addComponent<T : extends Script <T >>(constructor : (...args : unknown []) => T : extends Script <T >, bInReplicates? : boolean ): T : extends Script <T > other |
---|
Add a script component |
asyncGetChildByName(name : string ): Promise <GameObject > other |
Asynchronous search for sub objects based on their names |
asyncReady(): Promise <GameObject > other |
Return after the object is ready |
clone(gameObjectInfo? : GameObjectInfo ): GameObject other |
Copy Objects |
destroy(): void other |
delete object |
getBoundingBox(nonColliding? : boolean , includeFromChild? : boolean , outer? : Vector ): Vector other |
Get the size of the object's bounding box |
getBounds(onlyCollidingComponents : boolean , originOuter : Vector , boxExtentOuter : Vector , includeFromChild? : boolean ): void other |
Obtain object boundaries |
getChildByGameObjectId(gameObjectId : string ): GameObject other |
Search for sub objects based on gameObjectid |
getChildByName(name : string ): GameObject other |
Search for sub objects by name |
getChildByPath(path : string ): GameObject other |
Find sub objects according to path |
getChildren(): GameObject [] other |
Obtain sub objects |
getChildrenBoundingBoxCenter(outer? : Vector ): Vector other |
Get the center point of all child objects' bounding box (not including the parent object, if the parent object is unavailable, return [0,0,0]) |
getChildrenByName(name : string ): GameObject [] other |
Search for all sub objects by name |
getComponent<T : extends Script <T >>(constructor? : (...args : unknown []) => T : extends Script <T >): T : extends Script <T > other |
Get the component of the specified type |
getComponentPropertys<T : extends Script <T >>(constructor : (...args : unknown []) => T : extends Script <T >): Map <string , IPropertyOptions > other |
Get property of script component |
getComponents<T : extends Script <T >>(constructor? : (...args : unknown []) => T : extends Script <T >): T : extends Script <T >[] other |
Get all component of the specified type |
getCustomProperties(): string [] other |
Get all customize property |
getCustomProperty<T : extends CustomPropertyType >(propertyName : string ): T : extends CustomPropertyType other |
Get customize property |
getCustomPropertyChangeDelegate(property ): Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> other |
Event proxy triggered when a given object property is modified |
getPropertyChangeDelegate(property ): Readonly <MulticastDelegate <(path : string , value : unknown , oldValue : unknown ) => void >> other |
Event proxy triggered when a given object property is modified |
getVisibility(): boolean other |
Obtain whether the object is displayed |
isPrefabActor(): boolean other |
Return whether the current object is a prefabricated body |
moveBy(velocity : Vector , isLocal? : boolean ): void other |
Smoothly move an object over time according to a given velocity vector |
moveTo(targetPosition : Vector , time : number , isLocal? : boolean , onComplete? : () => void ): void other |
Smoothly move from the current position to the target position within the specified time |
rotateBy(rotation : Quaternion Rotation , multiplier : number , isLocal? : boolean ): void other |
Rotate the object smoothly over time according to the given rotation amount |
rotateTo(targetRotation : Quaternion Rotation , time : number , isLocal? : boolean , onComplete? : () => void ): void other |
Smoothly changes from the current rotation to the target rotation within the specified time |
scaleBy(scale : Vector , isLocal? : boolean ): void other |
Smoothly scale objects over time using a given scaling vector per second |
scaleTo(targetScale : Vector , time : number , isLocal? : boolean , onComplete? : () => void ): void other |
Smoothly changes from the current scale to the target scale within the specified time |
setAbsolute(absolutePosition? : boolean , absoluteRotation? : boolean , absoluteScale? : boolean ): void other |
Set whether the object localTransform is relative to the parent object or the world |
setCustomProperty(propertyName : string , value : undefined CustomPropertyType ): void other |
Set custom attributes |
setVisibility(status : boolean PropertyStatus , propagateToChildren? : boolean ): void other |
Set whether the object is displayed |
stopMove(): void other |
Interrupt further movement of moveTo() and moveBy() |
stopRotate(): void other |
Interrupt further rotation from rotateTo() or rotateBy() |
stopScale(): void other |
Interrupt further scale from ScaleTo() or ScaleBy() |
asyncFindGameObjectById(gameObjectId : string ): Promise <GameObject > other |
Asynchronous search for GameObject through gameObjectid |
asyncGetGameObjectByPath(path : string ): Promise <GameObject > other |
Asynchronously find objects through path |
asyncSpawn<T : extends GameObject <T >>(assetId : string , gameObjectInfo? : GameObjectInfo ): Promise <T : extends GameObject <T >> other |
Asynchronous construction of an object |
bulkPivotTo(gameObjects : GameObject [], transforms : Transform []): void other |
Batch set position |
findGameObjectById(gameObjectId : string ): GameObject other |
Search for objects through gameObjectid |
findGameObjectByName(name : string ): GameObject other |
Search for objects by name |
findGameObjectsByName(name : string ): GameObject [] other |
Search for objects by name |
findGameObjectsByTag(tag : string ): GameObject [] other |
Get objects through customize tag |
getGameObjectByPath(path : string ): GameObject other |
Search for objects through paths |
spawn<T : extends GameObject <T >>(assetId : string , gameObjectInfo? : GameObjectInfo ): T : extends GameObject <T > other |
Construct an object |
Properties
Accessors
Methods
addPassableTarget
• addPassableTarget(target
): void
other
Add permissions to the target through this area
Parameters
target GameObject | GameObject |
---|
Usage example: Add permission for other GameObjects to access this restricted area
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F1,()=>{
// F1 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
// Player character Add Access Permit
blockingVolume.addPassableTarget(player.character);
})
}
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F1,()=>{
// F1 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
// Player character Add Access Permit
blockingVolume.addPassableTarget(player.character);
})
}
clear
• clear(): void
other
Reset the blocking area
Usage example: reset all publish permits for the blocking area
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F4,()=>{
// F4 key notifies the server to execute an event
mw.Event.dispatchToServer(`Clear`);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`Clear`,()=>{
// Reset the access permit for the restricted area
blockingVolume.clear();
})
}
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F4,()=>{
// F4 key notifies the server to execute an event
mw.Event.dispatchToServer(`Clear`);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`Clear`,()=>{
// Reset the access permit for the restricted area
blockingVolume.clear();
})
}
getTargetPassable
• getTargetPassable(target
): boolean
other
Get permission for target to pass this area
Parameters
target GameObject | GameObject |
---|
Returns
boolean | bool |
---|
Usage example: Obtain the permission for a GameObject in this blocking area
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
InputUtil.onKeyDown(Keys.F3,()=>{
// F3 key to obtain player character's access permission
blockingVolume.getTargetPassable(player.character);
})
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
InputUtil.onKeyDown(Keys.F3,()=>{
// F3 key to obtain player character's access permission
blockingVolume.getTargetPassable(player.character);
})
removePassableTarget
• removePassableTarget(target
): void
other
Remove target's permission to pass this area
Parameters
target GameObject | GameObject |
---|
Usage example: Remove access permission for other GameObjects in this restricted area
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F2,()=>{
// F2 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`RemovePlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`RemovePlayerPassable`,(player : Player)=>{
// Player character removes access permit
blockingVolume.removePassableTarget(player.character);
})
}
// Get the current Player
let player = Player.localPlayer;
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncFindGameObjectById(`GUID`) as BlockingVolume;
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F2,()=>{
// F2 key informs the server that the execution event parameters are transferred to the current Player
mw.Event.dispatchToServer(`RemovePlayerPassable`,player);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`RemovePlayerPassable`,(player : Player)=>{
// Player character removes access permit
blockingVolume.removePassableTarget(player.character);
})
}
unblockAll
• unblockAll(): void
other
Open blocking area
Usage example: Open the no entry zone
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncSpawn<BlockingVolume>(`BlockingVolume`);
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F5,()=>{
// F5 key notifies the server to execute an event
mw.Event.dispatchToServer(`UnblockAll`);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`UnblockAll`,()=>{
// The blocking area is open to traffic
blockingVolume.unblockAll();
})
}
// The UID can be filled in according to the actual situation, and the object ID can be copied by right clicking in the editor object manager
let blockingVolume = await GameObject.asyncSpawn<BlockingVolume>(`BlockingVolume`);
if(SystemUtil.isClient())
{
InputUtil.onKeyDown(Keys.F5,()=>{
// F5 key notifies the server to execute an event
mw.Event.dispatchToServer(`UnblockAll`);
})
}
if(SystemUtil.isServer()){
// Listen for client notifications
mw.Event.addClientListener(`UnblockAll`,()=>{
// The blocking area is open to traffic
blockingVolume.unblockAll();
})
}