Esempio n. 1
0
        /// <summary>
        /// Recreate the default body shapes on the character's ActorController
        /// </summary>
        /// <param name="rMotionController"></param>
        public static void CreateDefaultBodyShapes(MotionController rMotionController)
        {
            ActorController lActorController = rMotionController.GetOrAddComponent <ActorController>();

            lActorController.BodyShapes.Clear();
            BodyCapsule lCapsule = new BodyCapsule
            {
                _Parent              = lActorController.transform,
                Name                 = "Body Capsule",
                Radius               = 0.3f,
                Offset               = new Vector3(0f, 0.6f, 0f),
                IsEnabledOnGround    = true,
                IsEnabledOnSlope     = true,
                IsEnabledAboveGround = true,
                EndTransform         = lActorController.transform.FindTransform(HumanBodyBones.Head)
            };

            if (lCapsule.EndTransform == null)
            {
                lCapsule.EndTransform = lActorController.transform.FindTransform("Head");
            }
            if (lCapsule.EndTransform == null)
            {
                lCapsule.EndOffset = new Vector3(0f, 1.6f, 0f);
            }

            lActorController.BodyShapes.Add(lCapsule);

            BodySphere lSphere = new BodySphere
            {
                _Parent              = lActorController.transform,
                Name                 = "Foot Sphere",
                Radius               = 0.25f,
                Offset               = new Vector3(0f, 0.25f, 0f),
                IsEnabledOnGround    = false,
                IsEnabledOnSlope     = false,
                IsEnabledAboveGround = true
            };

            lActorController.BodyShapes.Add(lSphere);

            // Save the new body shapes
            lActorController.SerializeBodyShapes();
        }
Esempio n. 2
0
    /// <summary>
    /// Initializes the shapes
    /// </summary>
    private void CreateDefaultShapes()
    {
        mTarget.BodyShapes.Clear();

        BodyCapsule lCapsule = new BodyCapsule();

        lCapsule._Parent              = mTarget.transform;
        lCapsule.Name                 = "Body Capsule";
        lCapsule.Radius               = 0.25f;
        lCapsule.Offset               = new Vector3(0f, 0.6f, 0f);
        lCapsule.IsEnabledOnGround    = true;
        lCapsule.IsEnabledOnSlope     = true;
        lCapsule.IsEnabledAboveGround = true;

        lCapsule.EndTransform = mTarget.transform.FindTransform(HumanBodyBones.Head);
        if (lCapsule.EndTransform == null)
        {
            lCapsule.EndTransform = mTarget.transform.FindTransform("Head");
        }
        if (lCapsule.EndTransform == null)
        {
            lCapsule.EndOffset = new Vector3(0f, 1.6f, 0f);
        }

        mTarget.BodyShapes.Add(lCapsule);

        BodySphere lSphere = new BodySphere();

        lSphere._Parent              = mTarget.transform;
        lSphere.Name                 = "Foot Sphere";
        lSphere.Radius               = 0.25f;
        lSphere.Offset               = new Vector3(0f, 0.25f, 0f);
        lSphere.IsEnabledOnGround    = false;
        lSphere.IsEnabledOnSlope     = false;
        lSphere.IsEnabledAboveGround = true;

        mTarget.BodyShapes.Add(lSphere);

        // Store the current body shapes
        mTarget.SerializeBodyShapes();
    }