Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  • Parameters in inspector
  • Available methods
  1. Basics
  2. Useful Components

Ragdoll

PreviousLabel ScalerNextRotate To Camera

Last updated 4 months ago

This component allows to turn your character with humanoid skeleton to ragdoll mode.

You should not add this component manually, use Tools/Heroic Engine/Components/Add Ragdoll option in Editor menu as shown below

After this, Ragdoll component will appear on your character gameobject.

This component will be added only in case if gameobject with Animator and Humanoid rig was selected in scene hierarchy!

Parameters in inspector

Animator – animator of humanoid character; this field will be automatically assigned by RagdollAdder utility

Hips – hips rigidbody of humanoid character; this field will be also automatically assigned by RagdollAdder utility

Ragdoll Mode At Start – if enabled, ragdoll mode will be activated automatically when character gameobject becomes active on scene


Available methods

public void SetRagdollMode(bool enable)

This method sets ragdoll mode. If enabled, character Animator will be disabled and skeleton will become completely physical. Otherwise, Animator will be active and bones will be moved by animations.

Example:

void Die()
{
    // If character dies, enable ragdoll so it falls to the ground
    if (ragdoll != null)
    {
        ragdoll.SetRagdollMode(true);
    }
}

public void Push(Vector3 direction, float force, ForceMode forceMode = ForceMode.Impulse)

Hehe, what can be more funny than pushing ragdoll? This method applies certain force to the character body with certain direction and automatically activates ragdoll mode on it.

Example:

// Push first found ragdoll on scene by F button push
if (Input.GetKeyDown(KeyCode.F))
{
    Ragdoll ragdoll = FindObjectOfType<Ragdoll>();
    if (ragdoll != null)
    {
        ragdoll.Push(ragdoll.transform.position - transform.position, 150f);
    }
}

public void AddTorque(Vector3 direction, float torque, ForceMode forceMode = ForceMode.Impulse)

This method applies certain rotation force to the character body and automatically activates its ragdoll mode.


Btw, you can see how it works on example scene which can be launched by the most top button in main menu.

How to add ragdoll to your character
How to add ragdoll to your character
Ragdoll component
Here you can start example scene with ragdoll interaction