Character Ragdoll
Quick toggling of ragdoll physics for characters
const ragdoll = this.gameObject.GetAirshipComponent<CharacterRagdoll>();
if (ragdoll) {
ragdoll.SetRagdoll(true);
ragdoll.AddExplosiveForce(
80, // Force value
ragdoll.transform.position, // Explosion center point
3, // Explosion radius
0.25, // Upwards force modifier
ForceMode.Impulse,
);
}OnDeath Example
import { Airship } from "@Easy/Core/Shared/Airship";
import { DamageInfo } from "@Easy/Core/Shared/Damage/DamageInfo";
import CharacterRagdoll from "@Easy/Core/Shared/Character/Animation/CharacterRagdoll";
export default class RagdollManager extends AirshipSingleton {
@Client()
protected Start() {
// Fetch ragdoll component on death and hand it off to the EnableRagdoll function
Airship.Damage.onDeath.Connect((damageInfo) => {
const character = damageInfo.gameObject.GetAirshipComponent<Character>();
const ragdoll = character?.rig.gameObject.GetAirshipComponent<CharacterRagdoll>();
if (ragdoll) {
this.EnableRagdoll(damageInfo, ragdoll);
}
});
}
private EnableRagdoll(damageInfo: DamageInfo, ragdoll: CharacterRagdoll) {
ragdoll.SetRagdoll(true);
// Add other effects here as desired, e.g. ragdoll.AddExplosiveForce()
}
}Last updated