Skip to content
CharacterDecoration

[Character System](../groups/Character System.Character System.md) / CharacterDecoration

CharacterDecoration Class

Character pendant slot

In addition to being able to freely change the character's clothes, face, and body, it is also possible to add more decorations to the character.

CharacterDecoration How to use it?

CharacterDescription In the CharacterDescription advanced humanoid configuration, there is a slotAndDecoration parameter left:

  • SlotOffset: An optional read-only attribute that represents information about the slot position and orientation.

  • Decoration: an optional read-only property that represents the information of the item. Is a CharacterDecoration customize type that contains additional decoration information about the item.

You can access it through the index and add decorations with asset in the left column, such as weapons, rings, halos, etc. Please refer to the interface and example code below for usage details.

Only the client exists.

Hierarchy

  • Array<{ attachmentAssetId: string;attachmentGameObject?: [GameObject](mw.GameObject.md) ; attachmentOffset?: Readonly<[Transform](mw.Transform.md)\> }>

    CharacterDecoration

Table of contents

Properties

Methods

add(decoration: string GameObject, attachmentOffset?: Transform): number other
Add a attachment to the current appearance slot
clear(isDestroy?: boolean): void other
Empty all attachment in the slot of the current appearance
delete(attachmentElement: number GameObject, isDestroy?: boolean): void other
Delete a attachment from the current slot

Properties

Methods


add

add(decoration, attachmentOffset?): number other

Add a attachment to the current appearance slot

Parameters

decoration string GameObjectUsage: attachment
attachmentOffset? TransformUsage: attachment transform information default: null

Returns

numberIndex of slot

Precautions

Attachment only support model objects

Usage example: drag the used asset: "60858" into the priority loading column. Create a script named "Example_CharacterDecoration_Add", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "1", and add a attachment to the character slot [Aperture overhead]. Press "2" on the keyboard to delete the first attachment in the [Aperture overhead] of the character slot. Press "3" on the keyboard to delete all attachment in [Aperture overhead] of the character slot. The code is as follows:

ts
@Component
export default class Example_CharacterDecoration_Add extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}
@Component
export default class Example_CharacterDecoration_Add extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}

clear

clear(isDestroy?): void other

Empty all attachment in the slot of the current appearance

Parameters

isDestroy? booleanUsage: Whether to destroy default: false

Usage example: Drag the resource "60858" into the priority loading bar. Create a script named "Example_CharacterDecoration_Clear", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "1", and add a attachment to the character slot [Aperture overhead]. Press keyboard "2" to delete the first pendant of the character slot "Crown Aperture". Press "3" on the keyboard to delete all attachment in [Aperture overhead] of the character slot. The code is as follows:

ts
@Component
export default class Example_CharacterDecoration_Clear extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}
@Component
export default class Example_CharacterDecoration_Clear extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}

delete

delete(attachmentElement, isDestroy?): void other

Delete a attachment from the current slot

Parameters

attachmentElement number GameObjectUsage: attachment
isDestroy? booleanUsage: Whether to destroy default: false

Usage example: drag the used asset: "60858" into the priority loading column. Create a script named "Example_CharacterDecoration_Delete", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "1", and add a attachment to the character slot [Aperture overhead]. Press keyboard "2" to delete the first pendant of the character slot "Crown Aperture". Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture". The code is as follows:

ts
@Component
export default class Example_CharacterDecoration_Delete extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}
@Component
export default class Example_CharacterDecoration_Delete extends Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected onStart(): void {
        // The following code is only executed on the client side
        if(SystemUtil.isClient()) {
            // Get the current client Player
            let myPlayer = Player.localPlayer;
            // Get Player control character
            let myCharacter = myPlayer.character;
            // Add a button method: Press keyboard "1" to add a pendant to the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.One, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.add("60858", new Transform(new Vector(0, 0, MathUtil.randomInt(0, 100)), Rotation.zero, Vector.one.multiply(0.1)));
                }
            });
            // Add a key method: press "2" on the keyboard to delete the first attachment in the character slot [Aperture overhead]
            InputUtil.onKeyDown(Keys.Two, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    let ring = myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration[0].attachmentGameObject;
                    if(ring) {
                        myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.delete(ring, true);
                    }
                }
            });
            // Add a button method: Press keyboard "3" to delete all the pendants in the character slot "Crown Aperture"
            InputUtil.onKeyDown(Keys.Three, () => {
                if(myCharacter.characterType == CharacterType.HumanoidV2) {
                    myCharacter.description.advance.slotAndDecoration.slot[HumanoidSlotType.Rings].decoration.clear(true);
                }
            });
        }
    }
}