Gameplay / RigidConstraint
RigidConstraint Class 
Physical link component
Precautions
Server settings, double end automatic sync
Example usage: Create a script called "RigidTest", place it in the object bar, open the script, enter the following code to save, run the game, and you will see a cube and a sphere in the scene. Set the rope constraint to enable it and perform a winch effect. The code is as follows:
@Component
export default class RigidTest extends Script {
    box:mw.Model;
    ball:mw.Model;
    rigid:mw.RigidConstraint;
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        if(SystemUtil.isServer()) {
            GameObject.asyncSpawn("197386",{replicates:true}).then((obj)=>{
                this.box = obj as mw.Model;
                this.box.worldTransform.position = new Vector(200,0,1200);
            });
            GameObject.asyncSpawn("197388",{replicates:true}).then((obj)=>{
                this.ball = obj as mw.Model;
                this.ball.worldTransform.position = new Vector(100,0,100);
                // The party using the linked component must enable physical simulation
                this.ball.physicsEnabled = true;
            })
            // Create Link component Link Box and Ball
            setTimeout(()=>{
                GameObject.asyncSpawn("RigidConstraint",{replicates:true}).then((obj)=>{
                    this.rigid = obj as mw.RigidConstraint;
                    this.rigid.constraint1 = this.box;
                    this.rigid.constraint2 = this.ball;
                    this.rigid.softConstraintEnabled = true;
                    this.rigid.length = 800;
                    this.rigid.autoEnable = true;
                    // Open the hinge and pull the ball to the target position
                    setTimeout(() => {
                        this.rigid.winchEnabled = true;
                        this.rigid.winchForce = 10000;
                        this.rigid.winchSpeed = 150;
                        this.rigid.winchTarget = 200;
                    }, 5000);
                })
            }, 10000);
        }
    }
}@Component
export default class RigidTest extends Script {
    box:mw.Model;
    ball:mw.Model;
    rigid:mw.RigidConstraint;
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        if(SystemUtil.isServer()) {
            GameObject.asyncSpawn("197386",{replicates:true}).then((obj)=>{
                this.box = obj as mw.Model;
                this.box.worldTransform.position = new Vector(200,0,1200);
            });
            GameObject.asyncSpawn("197388",{replicates:true}).then((obj)=>{
                this.ball = obj as mw.Model;
                this.ball.worldTransform.position = new Vector(100,0,100);
                // The party using the linked component must enable physical simulation
                this.ball.physicsEnabled = true;
            })
            // Create Link component Link Box and Ball
            setTimeout(()=>{
                GameObject.asyncSpawn("RigidConstraint",{replicates:true}).then((obj)=>{
                    this.rigid = obj as mw.RigidConstraint;
                    this.rigid.constraint1 = this.box;
                    this.rigid.constraint2 = this.ball;
                    this.rigid.softConstraintEnabled = true;
                    this.rigid.length = 800;
                    this.rigid.autoEnable = true;
                    // Open the hinge and pull the ball to the target position
                    setTimeout(() => {
                        this.rigid.winchEnabled = true;
                        this.rigid.winchForce = 10000;
                        this.rigid.winchSpeed = 150;
                        this.rigid.winchTarget = 200;
                    }, 5000);
                })
            }, 10000);
        }
    }
}Hierarchy 
- ↳ - RigidConstraint
Table of contents 
Properties 
| onWinchComplete: MulticastDelegate<() =>void> | 
|---|
| Trigger callback function when winch reaches target | 
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 
| autoEnable(): boolean | 
|---|
| Automatically enable constraint effects at runtime | 
| constraint1(): GameObject | 
| Constrained object 1, the current constraint types are model, character, NPC, and vehicle, and other object constraints are invalid | 
| constraint2(): GameObject | 
| Constraint object 2, the current constraint type is model, character, NPC, vehicle, and other object constraint are invalid | 
| currentDistance(): number | 
| Distance between two constraint objects | 
| isVisible(): boolean | 
| Display connection line | 
| length(): number | 
| Set the maximum connection distance of the two constraint objects. When the current distance of the two constraint objects is greater than the connection length, the Rigid Constraint will automatically shrink, and then the two constraint objects will be pulled to the set distance | 
| softConstraintEnabled(): boolean | 
| After enabling the soft connection, the distance between two constrained objects cannot exceed the limit of the connection length, and can be shorter than the connection length and rotate freely. The hinge disc function can be used after opening the Soft Constraint | 
| winchEnabled(): boolean | 
| After opening, Soft Constraint automatically executes the effect of hinge disk | 
| winchForce(): number | 
| Set the tension of the winch, the larger the target mass to be pulled, the greater the required tension | 
| winchSpeed(): number | 
| Set winch movement speed (cm/s) | 
| winchTarget(): number | 
| Set the target distance of Winch movement. When the distance between two constraint objects reaches the target of Winch, stop the movement | 
click
Accessors 
| actorFlagValue(): numberother | 
|---|
| Get object tags | 
| actorLevel(): numberother | 
| Obtain Actor Level | 
| assetId(): stringother | 
| Retrieve the UID of the resource currently being used by the object | 
| gameObjectId(): stringother | 
| Get the unique identification of an object (a string that uniquely identifies an object). | 
| isDestroyed(): booleanother | 
| Has the current object been destroyed | 
| isReady(): booleanother | 
| Current object status | 
| localTransform(): Transformother | 
| Local transformation of the current object | 
| name(): stringother | 
| Return the current object name | 
| netStatus(): NetStatusother | 
| Get the current object synchronization status | 
| parent(): GameObjectother | 
| Retrieve the current parent object | 
| tag(): stringother | 
| Get the tag of the current object | 
| worldTransform(): Transformother | 
| Current object world transformation | 
Methods 
click
Methods 
| addComponent< T: extendsScript<T>>(constructor: (...args:unknown[]) =>T: extendsScript<T>,bInReplicates?:boolean):T: extendsScript<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):GameObjectother | 
| Copy Objects | 
| destroy(): voidother | 
| delete object | 
| getBoundingBox( nonColliding?:boolean,includeFromChild?:boolean,outer?:Vector):Vectorother | 
| Get the size of the object's bounding box | 
| getBounds( onlyCollidingComponents:boolean,originOuter:Vector,boxExtentOuter:Vector,includeFromChild?:boolean):voidother | 
| Obtain object boundaries | 
| getChildByGameObjectId( gameObjectId:string):GameObjectother | 
| Search for sub objects based on gameObjectid | 
| getChildByName( name:string):GameObjectother | 
| Search for sub objects by name | 
| getChildByPath( path:string):GameObjectother | 
| Find sub objects according to path | 
| getChildren(): GameObject[] other | 
| Obtain sub objects | 
| getChildrenBoundingBoxCenter( outer?:Vector):Vectorother | 
| 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: extendsScript<T>>(constructor?: (...args:unknown[]) =>T: extendsScript<T>):T: extendsScript<T> other | 
| Get the component of the specified type | 
| getComponentPropertys< T: extendsScript<T>>(constructor: (...args:unknown[]) =>T: extendsScript<T>):Map<string,IPropertyOptions> other | 
| Get property of script component | 
| getComponents< T: extendsScript<T>>(constructor?: (...args:unknown[]) =>T: extendsScript<T>):T: extendsScript<T>[] other | 
| Get all component of the specified type | 
| getCustomProperties(): string[] other | 
| Get all customize property | 
| getCustomProperty< T: extendsCustomPropertyType>(propertyName:string):T: extendsCustomPropertyTypeother | 
| 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(): booleanother | 
| Obtain whether the object is displayed | 
| isPrefabActor(): booleanother | 
| Return whether the current object is a prefabricated body | 
| moveBy( velocity:Vector,isLocal?:boolean):voidother | 
| Smoothly move an object over time according to a given velocity vector | 
| moveTo( targetPosition:Vector,time:number,isLocal?:boolean,onComplete?: () =>void):voidother | 
| Smoothly move from the current position to the target position within the specified time | 
| rotateBy( rotation:QuaternionRotation,multiplier:number,isLocal?:boolean):voidother | 
| Rotate the object smoothly over time according to the given rotation amount | 
| rotateTo( targetRotation:QuaternionRotation,time:number,isLocal?:boolean,onComplete?: () =>void):voidother | 
| Smoothly changes from the current rotation to the target rotation within the specified time | 
| scaleBy( scale:Vector,isLocal?:boolean):voidother | 
| Smoothly scale objects over time using a given scaling vector per second | 
| scaleTo( targetScale:Vector,time:number,isLocal?:boolean,onComplete?: () =>void):voidother | 
| Smoothly changes from the current scale to the target scale within the specified time | 
| setAbsolute( absolutePosition?:boolean,absoluteRotation?:boolean,absoluteScale?:boolean):voidother | 
| Set whether the object localTransform is relative to the parent object or the world | 
| setCustomProperty( propertyName:string,value:undefinedCustomPropertyType):voidother | 
| Set custom attributes | 
| setVisibility( status:booleanPropertyStatus,propagateToChildren?:boolean):voidother | 
| Set whether the object is displayed | 
| stopMove(): voidother | 
| Interrupt further movement of moveTo() and moveBy() | 
| stopRotate(): voidother | 
| Interrupt further rotation from rotateTo() or rotateBy() | 
| stopScale(): voidother | 
| 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: extendsGameObject<T>>(assetId:string,gameObjectInfo?:GameObjectInfo):Promise<T: extendsGameObject<T>> other | 
| Asynchronous construction of an object | 
| bulkPivotTo( gameObjects:GameObject[],transforms:Transform[]):voidother | 
| Batch set position | 
| findGameObjectById( gameObjectId:string):GameObjectother | 
| Search for objects through gameObjectid | 
| findGameObjectByName( name:string):GameObjectother | 
| 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):GameObjectother | 
| Search for objects through paths | 
| spawn< T: extendsGameObject<T>>(assetId:string,gameObjectInfo?:GameObjectInfo):T: extendsGameObject<T> other | 
| Construct an object | 
Properties 
onWinchComplete 
• onWinchComplete: MulticastDelegate<() => void>
Trigger callback function when winch reaches target
Accessors 
autoEnable 
| •  | •  | ||||
|---|---|---|---|---|---|
| Automatically enable constraint effects at runtime Returns 
 | Automatically enable constraint effects at runtime Parameters 
 | 
constraint1 
| •  | •  | ||||
|---|---|---|---|---|---|
| Constrained object 1, the current constraint types are model, character, NPC, and vehicle, and other object constraints are invalid Returns 
 | Constrained object 1, the current constraint types are model, character, NPC, and vehicle, and other object constraints are invalid Parameters 
 | 
constraint2 
| •  | •  | ||||
|---|---|---|---|---|---|
| Constraint object 2, the current constraint type is model, character, NPC, vehicle, and other object constraint are invalid Returns 
 | Constraint object 2, the current constraint type is model, character, NPC, vehicle, and other object constraint are invalid Parameters 
 | 
currentDistance 
| •  | ||
|---|---|---|
| Distance between two constraint objects Returns 
 | 
isVisible 
| •  | •  | ||||
|---|---|---|---|---|---|
| Display connection line Returns 
 | Display connection line Parameters 
 | 
length 
| •  | •  | ||||
|---|---|---|---|---|---|
| Set the maximum connection distance of the two constraint objects. When the current distance of the two constraint objects is greater than the connection length, the Rigid Constraint will automatically shrink, and then the two constraint objects will be pulled to the set distance Returns 
 | Set the maximum connection distance of the two constraint objects. When the current distance of the two constraint objects is greater than the connection length, the Rigid Constraint will automatically shrink, and then the two constraint objects will be pulled to the set distance Parameters 
 | 
softConstraintEnabled 
| •  | •  | ||||
|---|---|---|---|---|---|
| After enabling the soft connection, the distance between two constrained objects cannot exceed the limit of the connection length, and can be shorter than the connection length and rotate freely. The hinge disc function can be used after opening the Soft Constraint Returns 
 | After enabling the soft connection, the distance between two constrained objects cannot exceed the limit of the connection length, and can be shorter than the connection length and rotate freely. The hinge disc function can be used after opening the Soft Constraint Parameters 
 | 
winchEnabled 
| •  | •  | ||||
|---|---|---|---|---|---|
| After opening, Soft Constraint automatically executes the effect of hinge disk Returns 
 | After opening, Soft Constraint automatically executes the effect of hinge disk Parameters 
 | 
winchForce 
| •  | •  | ||||
|---|---|---|---|---|---|
| Set the tension of the winch, the larger the target mass to be pulled, the greater the required tension Returns 
 | Set the tension of the winch, the larger the target mass to be pulled, the greater the required tension Parameters 
 | 
winchSpeed 
| •  | •  | ||||
|---|---|---|---|---|---|
| Set winch movement speed (cm/s) Returns 
 | Set winch movement speed (cm/s) Parameters 
 | 
winchTarget 
| •  | •  | ||||
|---|---|---|---|---|---|
| Set the target distance of Winch movement. When the distance between two constraint objects reaches the target of Winch, stop the movement Returns 
 | Set the target distance of Winch movement. When the distance between two constraint objects reaches the target of Winch, stop the movement Parameters 
 | 
 Editor API
Editor API