Creature Kit v1.1 Procedural Creature Creation for Unity
Search Results for

    Show / Hide Table of Contents
    Documentation
    Home Animation Channels Guide Clips Guide No-Code Guide API Reference

    Accessing Generated Beast Parts

    Application code can read the generated anatomy through BeastStructure.Parts. This is the supported entry point for locating the Body, Head, feet, eyes, tails, and other generated transforms without searching the hierarchy by name.

    Beast construction remains an Inspector workflow. The API described here reads an already generated Beast; it does not create or reshape one from code.

    Get The Current Parts

    using CreatureKit.Beasts;
    using UnityEngine;
    
    public sealed class BeastPartReader : MonoBehaviour
    {
        [SerializeField] private BeastStructure beast;
    
        private Transform body;
    
        private void OnEnable()
        {
            if (beast == null)
                beast = GetComponent<BeastStructure>();
    
            if (beast == null)
                return;
    
            if (beast.HasGeneratedParts || beast.TryRecoverGeneratedParts())
                BindParts(beast.Parts);
    
            beast.RigRebuilt += HandleRigRebuilt;
            beast.RigCleared += HandleRigCleared;
        }
    
        private void OnDisable()
        {
            if (beast == null)
                return;
    
            beast.RigRebuilt -= HandleRigRebuilt;
            beast.RigCleared -= HandleRigCleared;
        }
    
        private void HandleRigRebuilt(BeastStructure source, BeastParts rebuiltParts)
        {
            BindParts(rebuiltParts);
        }
    
        private void HandleRigCleared(BeastStructure source)
        {
            body = null;
        }
    
        private void BindParts(BeastParts parts)
        {
            body = parts != null ? parts.Body : null;
    
            if (parts == null)
                return;
    
            foreach (BeastLegRig leg in parts.Legs)
            {
                if (leg != null && leg.Foot != null)
                    Debug.Log($"Foot: {leg.Foot.name}", leg.Foot);
            }
        }
    }
    

    TryRecoverGeneratedParts reconnects BeastStructure to an existing generated hierarchy. It does not generate a new Beast.

    BeastParts Reference

    All single-part properties are Transform references. Optional disabled parts can be null; collection properties remain available and can be empty.

    Property Generated part
    Root Root of the generated Beast hierarchy.
    Body Main Body transform.
    NeckAnchor, Neck Neck attachment and Neck transform.
    HeadAnchor, Head Head attachment and Head transform.
    MouthAnchor Mouth attachment below the Head.
    UpperJaw, JawPivot, LowerJaw Generated mouth and jaw transforms.
    Eyes, EyeRigs Eye transforms and detailed eye rigs.
    Ears, EarRigs Ear transforms and detailed ear rigs.
    TailAnchor, Tail First generated tail attachment and tail, provided as convenience references.
    Tails, TailRigs Every generated tail and its detailed rig.
    Legs Every generated BeastLegRig.

    Detailed Rig References

    Use the rig collections when a system needs anchors, joints, or generated contact references rather than only the visible part transform.

    Rig Useful properties
    BeastEyeRig Anchor, Eye, PupilMesh, UpperEyelid, LowerEyelid, Index.
    BeastEarRig Anchor, Ear, Index.
    BeastTailRig Anchor, Tail, Index.
    BeastLegRig Anchor, Root, UpperLeg, Knee, LowerLeg, Ankle, Foot, GroundContact, FootTarget, KneePole, PairIndex, SideSign.

    For legs, PairIndex identifies the pair along the body. SideSign is negative for the left side and positive for the right side. GroundContact is the generated theoretical sole center used by ground sampling; FootTarget is a rig target and is not the sole position.

    Rebuild Safety

    Generated Beast is rebuild-owned output. A structure rebuild replaces its transforms and the current BeastParts object, so references cached before the rebuild are no longer valid.

    • Subscribe to RigRebuilt when retaining generated-part references.
    • Clear cached references when RigCleared is raised.
    • Do not search for generated objects by hierarchy name when Parts provides the reference.
    • Do not parent persistent gameplay objects below a generated part; keep them application-owned and make them follow the current part reference.
    • Treat BeastParts and its rig collections as read-only anatomy references.

    Construction Boundary

    Create and reshape Beasts with the BeastStructure Inspector and Structure Presets. Programmatic Beast construction and direct mutation of the generated-part registry are not documented or supported workflows.

    Back to top Generated by DocFX