Animation / SubStance
SubStance Class
Second level posture
The secondary stance is an extension of the animation system, which is used to achieve complex animation logic (such as gun holding, climbing, etc.) independent of the basic stance.
The basic secondary stance asset is also an external asset with the basic stance. After packaging, the generate file is uploaded to the asset server. You can find and download them under the basic stance category in the local asset library.
It also has functions such as loadSubStance, play, stop, etc
There are also additional excellent blending modes, see StanceBlendMode for details.
Hierarchy
StanceBase
↳
SubStance
Table of contents
Accessors
assetId(): string |
---|
Asset GUID |
blendMode(): StanceBlendMode other |
Mixed mode of stance |
Methods
play(): boolean other |
---|
Play posture |
stop(): boolean other |
Stop the stance object and return the execution result |
Accessors
assetId
• | ||
---|---|---|
Asset GUID Usage example: drag the used asset: "9426114520" into the priority loading column. Create a script named 'Instance_SubStance_SessetId', place it in the object bar, open the script, enter the following code to save, run the game, load a aiming pose with only the upper body and a kicking pose with only the lower body on the player character, press the keyboard '1', switch between playing aiming pose and kicking pose. You will see the effect of character's different stance in the scene. Press "2" on the keyboard to stop playing stance. The code is as follows: ts
Returns
|
blendMode
• | • | ||||
---|---|---|---|---|---|
Mixed mode of stance Precautions The playing position of stance (upper body, lower body, whole body) is invalid when the stance being played is modified If the stance is create by prefabricating the stance asset GUID, its default value will be automatically obtained from the asset; If it is created through animation resource UID, its default value is StanceBlendMode WholeBody. Usage example: drag the used asset: "9426114520" into the priority loading column. Create a script named 'Instance_SubStance_SlendMode', place it in the object bar, open the script, enter the following code to save, run the game, load a aiming pose with only the upper body and a kicking pose with only the lower body on the player character, press the keyboard '1', switch between playing aiming pose and kicking pose. You will see the effects of different poses of characters in the scene. Press keyboard "2" to stop the playback posture. The code is as follows: ts
Returns
| Mixed mode of stance Precautions The playing position of stance (upper body, lower body, whole body) is invalid when the stance being played is modified If the stance is create by prefabricating the stance asset GUID, its default value will be automatically obtained from the asset; If it is created through animation resource UID, its default value is StanceBlendMode WholeBody. Usage example: drag the used asset: "9426114520" into the priority loading column. Create a script named 'Instance_SubStance_SlendMode', place it in the object bar, open the script, enter the following code to save, run the game, load a aiming pose with only the upper body and a kicking pose with only the lower body on the player character, press the keyboard '1', switch between playing aiming pose and kicking pose. You will see the effects of different poses of characters in the scene. Press keyboard "2" to stop the playback posture. The code is as follows: ts
Parameters
|
Methods
play
• play(): boolean
other
Play posture
Returns
boolean | The playback result will return false when the asset is not loaded, but the asset will be loaded asynchronously internally and played after completion. |
---|
Precautions
Play the stance object and return the execution result Whether this operation will automatically synchronize multiple ends depends on the call end, the server side broadcasting takes effect, and the client side takes effect locally.
Usage example: drag the used asset: "9426114520" into the priority loading column. Create a script named "Example_SubStance_Play", place it in the object bar, open the script, enter the following code to save, run the game, load a Player's character with a aim stance of only the upper body and a kicking stance of only the lower body, press the keyboard "1" to switch between playing the aim stance and kicking stance. You will see the effects of different poses of characters in the scene. Press "2" on the keyboard to stop playing stance. The code is as follows:
@Component
export default class Example_SubStance_Play 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;
// Load only upper aim stance for character
let aimStance = myCharacter.loadSubStance("94261");
aimStance.blendMode = StanceBlendMode.BlendUpper;
console.log("aimStance assetId " + aimStance.assetId);
// Load the character with only lower body kicking posture
let kickStance = myCharacter.loadSubStance("14520");
kickStance.blendMode = StanceBlendMode.BlendLower;
console.log("kickStance assetId " + kickStance.assetId);
// Add a key method: press the keyboard "1" to switch between aim stance and kicking stance
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentSubStance == aimStance) {
kickStance.play();
} else {
aimStance.play();
}
});
// Add a button method: Press keyboard "2" to stop playing posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentSubStance) {
myCharacter.currentSubStance.stop();
}
});
}
}
}
@Component
export default class Example_SubStance_Play 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;
// Load only upper aim stance for character
let aimStance = myCharacter.loadSubStance("94261");
aimStance.blendMode = StanceBlendMode.BlendUpper;
console.log("aimStance assetId " + aimStance.assetId);
// Load the character with only lower body kicking posture
let kickStance = myCharacter.loadSubStance("14520");
kickStance.blendMode = StanceBlendMode.BlendLower;
console.log("kickStance assetId " + kickStance.assetId);
// Add a key method: press the keyboard "1" to switch between aim stance and kicking stance
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentSubStance == aimStance) {
kickStance.play();
} else {
aimStance.play();
}
});
// Add a button method: Press keyboard "2" to stop playing posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentSubStance) {
myCharacter.currentSubStance.stop();
}
});
}
}
}
stop
• stop(): boolean
other
Stop the stance object and return the execution result
Returns
boolean | Stop result |
---|
Precautions
Stop this posture object and return the execution result Whether this operation will automatically synchronize multiple ends depends on the call end, the server side broadcasting takes effect, and the client side takes effect locally.
Usage example: Drag the resource "9426114520" into the priority loading bar. Create a script named "Example_SubStance_Stop", place it in the object bar, open the script, enter the following code to save it, run the game, load a Player character with a aim stance of only the upper body and a kicking stance of only the lower body, press the keyboard "1" to switch between playing the aim stance and kicking stance. You will see the effects of different poses of characters in the scene. Press "2" on the keyboard to stop playing stance. The code is as follows:
@Component
export default class Example_SubStance_Stop 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;
// Load only upper aim stance for character
let aimStance = myCharacter.loadSubStance("94261");
aimStance.blendMode = StanceBlendMode.BlendUpper;
console.log("aimStance assetId " + aimStance.assetId);
// Load the character with only lower body kicking posture
let kickStance = myCharacter.loadSubStance("14520");
kickStance.blendMode = StanceBlendMode.BlendLower;
console.log("kickStance assetId " + kickStance.assetId);
// Add a key method: press the keyboard "1" to switch between aim stance and kicking stance
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentSubStance == aimStance) {
kickStance.play();
} else {
aimStance.play();
}
});
// Add a button method: Press keyboard "2" to stop playing posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentSubStance) {
myCharacter.currentSubStance.stop();
}
});
}
}
}
@Component
export default class Example_SubStance_Stop 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;
// Load only upper aim stance for character
let aimStance = myCharacter.loadSubStance("94261");
aimStance.blendMode = StanceBlendMode.BlendUpper;
console.log("aimStance assetId " + aimStance.assetId);
// Load the character with only lower body kicking posture
let kickStance = myCharacter.loadSubStance("14520");
kickStance.blendMode = StanceBlendMode.BlendLower;
console.log("kickStance assetId " + kickStance.assetId);
// Add a key method: press the keyboard "1" to switch between aim stance and kicking stance
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentSubStance == aimStance) {
kickStance.play();
} else {
aimStance.play();
}
});
// Add a button method: Press keyboard "2" to stop playing posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentSubStance) {
myCharacter.currentSubStance.stop();
}
});
}
}
}