Animation / Stance
Stance Class
Basic stance
The basic stance includes animation state machines for ground, flight and swimming. When you directly enter the game without any modification, all kinds of actions such as walking, running and jumping of character are performed by it.
The basic stance asset is an external asset. You can find and download them under the basic stance category in the local asset library.
Stance How does it work?
To play the basic stance, first execute the loadStance method in the Character class. Load a base stance object.
You can modify some property of this basic stance object and call the play method. The basic stance asset will be downloaded and loaded asynchronously when call play.
To stop a basic stance object, you can directly call call on the basic stance object.
Hierarchy
StanceBase
↳
Stance
Table of contents
Accessors
aimOffsetEnabled(): boolean other |
---|
Enable aim offset |
assetId(): string |
Attitude Resource Identifier |
Methods
play(): boolean other |
---|
Play posture |
stop(): boolean other |
Stop posture |
Accessors
aimOffsetEnabled
• | • | ||||
---|---|---|---|---|---|
Enable aim offset Precautions Whether the character has enabled aiming offset. True means enable, and false means disable. Aim offset is used to create a multi-directional weapon aim hybrid structure, and then superimpose and apply it to the default aim pose. Usage example: drag the used asset: "23442316081" into the priority loading column. Create a script named "Example_Stance_AimOffsetEnabled", place it in the object bar, open the script, enter the following code to save it, run the game, load a anime basic male stance and a anime basic female stance on the Player's character, press the keyboard "1", switch between playing anime basic male stance and anime basic female stance. You will see the effect of character's different stance in the scene. Press "2" on the keyboard to stop playing the basic stance. The code is as follows: ts
Returns
| Enable aim offset Precautions Whether the character has enabled aiming offset. True means enable, and false means disable. Aim offset is used to create a multi-directional weapon aim hybrid structure, and then superimpose and apply it to the default aim pose. Usage example: drag the used asset: "23442316081" into the priority loading column. Create a script named "Example_Stance_AimOffsetEnabled", place it in the object bar, open the script, enter the following code to save it, run the game, load a anime basic male stance and a anime basic female stance on the Player's character, press the keyboard "1", switch between playing anime basic male stance and anime basic female stance. You will see the effects of different poses of characters in the scene. Press keyboard "2" to stop playing the basic posture. The code is as follows: ts
Parameters
|
assetId
• |
---|
Attitude Resource Identifier Usage example: Drag the resource "234423216081" into the priority loading bar. Create a script named "Example_Stande_AssetId", place it in the object bar, open the script, enter the following code to save it, run the game, load a anime basic male stance and a anime basic female stance on the Player's character, press the keyboard "1", switch to play the anime basic male stance and anime basic female stance. You will see the effect of character's different stance in the scene. Press "2" on the keyboard to stop playing the basic stance. The code is as follows: ts
Returns |
string |
---|
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: "23442316081" into the priority loading column. Create a script named "Example_Stande_Play", place it in the object bar, open the script, enter the following code to save it, run the game, load a anime basic male stance and a anime basic female stance on the Player's character, press the keyboard "1", switch between playing anime basic male stance and anime basic female stance. You will see the effect of character's different stance in the scene. Press keyboard "2" to stop playing the basic posture. The code is as follows:
@Component
export default class Example_Stance_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 a anime male basic stance to the character
let animeManStance = myCharacter.loadStance("234423");
console.log("animeManStance assetId " + animeManStance.assetId);
// Load a anime female basic stance for the character (default), and turn off aim offset
let animeWomanStance = myCharacter.loadStance("216081");
animeWomanStance.aimOffsetEnabled = false;
console.log("animeWomanStance assetId " + animeWomanStance.assetId);
// Add a button method: Press keyboard "1" to switch between playing 2D male basic poses and 2D female basic poses
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentStance == animeWomanStance) {
animeManStance.play();
// Enable aim offset
animeManStance.aimOffsetEnabled = true;
} else {
animeWomanStance.play();
// Close aim offset
animeWomanStance.aimOffsetEnabled = false;
}
});
// Add a button method: Press keyboard "2" to stop playing the basic posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentStance) {
myCharacter.currentStance.stop();
}
});
}
}
}
@Component
export default class Example_Stance_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 a anime male basic stance to the character
let animeManStance = myCharacter.loadStance("234423");
console.log("animeManStance assetId " + animeManStance.assetId);
// Load a anime female basic stance for the character (default), and turn off aim offset
let animeWomanStance = myCharacter.loadStance("216081");
animeWomanStance.aimOffsetEnabled = false;
console.log("animeWomanStance assetId " + animeWomanStance.assetId);
// Add a button method: Press keyboard "1" to switch between playing 2D male basic poses and 2D female basic poses
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentStance == animeWomanStance) {
animeManStance.play();
// Enable aim offset
animeManStance.aimOffsetEnabled = true;
} else {
animeWomanStance.play();
// Close aim offset
animeWomanStance.aimOffsetEnabled = false;
}
});
// Add a button method: Press keyboard "2" to stop playing the basic posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentStance) {
myCharacter.currentStance.stop();
}
});
}
}
}
stop
• stop(): boolean
other
Stop posture
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 used asset: "23442316081" into the priority loading column. Create a script named "Example_Stande_Stop", place it in the object bar, open the script, enter the following code to save it, run the game, load a anime basic male stance and a anime basic female stance on the Player's character, press the keyboard "1", switch to play the anime basic male stance and anime basic female stance. You will see the effect of character's different stance in the scene. Press "2" on the keyboard to stop playing the basic stance. The code is as follows:
@Component
export default class Example_Stance_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 a anime male basic stance to the character
let animeManStance = myCharacter.loadStance("234423");
console.log("animeManStance assetId " + animeManStance.assetId);
// Load a anime female basic stance for the character (default), and turn off aim offset
let animeWomanStance = myCharacter.loadStance("216081");
animeWomanStance.aimOffsetEnabled = false;
console.log("animeWomanStance assetId " + animeWomanStance.assetId);
// Add a button method: Press keyboard "1" to switch between playing 2D male basic poses and 2D female basic poses
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentStance == animeWomanStance) {
animeManStance.play();
// Enable aim offset
animeManStance.aimOffsetEnabled = true;
} else {
animeWomanStance.play();
// Close aim offset
animeWomanStance.aimOffsetEnabled = false;
}
});
// Add a button method: Press keyboard "2" to stop playing the basic posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentStance) {
myCharacter.currentStance.stop();
}
});
}
}
}
@Component
export default class Example_Stance_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 a anime male basic stance to the character
let animeManStance = myCharacter.loadStance("234423");
console.log("animeManStance assetId " + animeManStance.assetId);
// Load a anime female basic stance for the character (default), and turn off aim offset
let animeWomanStance = myCharacter.loadStance("216081");
animeWomanStance.aimOffsetEnabled = false;
console.log("animeWomanStance assetId " + animeWomanStance.assetId);
// Add a button method: Press keyboard "1" to switch between playing 2D male basic poses and 2D female basic poses
InputUtil.onKeyDown(Keys.One, () => {
if(myCharacter.currentStance == animeWomanStance) {
animeManStance.play();
// Enable aim offset
animeManStance.aimOffsetEnabled = true;
} else {
animeWomanStance.play();
// Close aim offset
animeWomanStance.aimOffsetEnabled = false;
}
});
// Add a button method: Press keyboard "2" to stop playing the basic posture
InputUtil.onKeyDown(Keys.Two, () => {
if(myCharacter.currentStance) {
myCharacter.currentStance.stop();
}
});
}
}
}