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)); } }
public static FreefallMotion Create(GameObject parent, Rigidbody charBody, Collider charCollider) { FreefallMotion motion = parent.GetComponent <FreefallMotion>(); if (motion == null) { motion = parent.AddComponent <FreefallMotion>(); } motion._charBody = charBody; motion._charCollider = charCollider; return(motion); }