Example #1
0
        void Init()
        {
            if (_charBody == null)
            {
                _charBody = gameObject.GetComponent <Rigidbody>();
            }
            _charBody.isKinematic = true;

            if (_charCollider == null)
            {
                _charCollider = gameObject.GetComponent <Collider>();
            }

            if (!_charMotions.ContainsKey(CharState.Freefalling))
            {
                _charMotions.Add(CharState.Freefalling, FreefallMotion.Create(this.gameObject, _charBody, _charCollider));
            }

            if (!_charMotions.ContainsKey(CharState.Walking))
            {
                _charMotions.Add(CharState.Walking, WalkMotion.Create(this.gameObject, _charBody, _charCollider));
            }

            if (!_charMotions.ContainsKey(CharState.Grappling))
            {
                _charMotions.Add(CharState.Grappling, GrappleMotion.Create(this.gameObject, _charBody, _charCollider));
            }
        }
Example #2
0
        public static WalkMotion Create(GameObject parent, Rigidbody charBody, Collider charCollider)
        {
            WalkMotion motion = parent.GetComponent <WalkMotion>();

            if (motion == null)
            {
                motion = parent.AddComponent <WalkMotion>();
            }

            motion._charBody     = charBody;
            motion._charCollider = charCollider;

            return(motion);
        }