Ragdoll function
It takes about 5 minutes to read this article
This article provides an overview of what ragdoll is and how to use the function.
Ragdoll Introduction
Ragdoll definition: Ragdoll is an uncontrollable state of a character with physical effects.
Usage: The character has been fatally injured and is unconscious, so the body parts will be driven by physics simulation. Thus, the ragdoll can be used to simulate the character's death state and other behaviors.
How to use the ragdoll feature
enable/disable ragdoll
Practical application: After the character enable the ragdoll effect, the character will be affected by other external forces.
Sample script:
ts
@Component
export default class NewScript extends Script {
/** When the script is instantiated, this function will be call before the first frame is update */
protected onStart(): void {
//Get the Player character
let chara = Player.localPlayer.character
// press the "1" key to trigger the following logic
InputUtil.onKeyDown(Keys.One, () => {
// character ragdoll effect is turned on
chara.ragdollEnabled = true;
});
// press the "2" key to trigger the following logic
InputUtil.onKeyDown(Keys.Two, () => {
// character ragdoll effect turned off
chara.ragdollEnabled = false;
});
}
}
@Component
export default class NewScript extends Script {
/** When the script is instantiated, this function will be call before the first frame is update */
protected onStart(): void {
//Get the Player character
let chara = Player.localPlayer.character
// press the "1" key to trigger the following logic
InputUtil.onKeyDown(Keys.One, () => {
// character ragdoll effect is turned on
chara.ragdollEnabled = true;
});
// press the "2" key to trigger the following logic
InputUtil.onKeyDown(Keys.Two, () => {
// character ragdoll effect turned off
chara.ragdollEnabled = false;
});
}
}