private void Start() { this.m_CameraTransform = Camera.main.transform; this.m_Transform = transform; this.m_Animator = GetComponent <Animator>(); this.m_Controller = GetComponent <ThirdPersonController>(); EventHandler.Register <bool>(gameObject, "OnSetControllerActive", OnSetControllerActive); }
public void StartMove(ThirdPersonController controller) { this.m_CanMove = true; this.m_MoveDirection = controller.transform.forward; this.m_MoveDirection.y = 0f; this.m_Moving = true; this.m_Controller = controller; }
private void OnEnable() { this.m_Controller = target as ThirdPersonController; this.m_GameObject = this.m_Controller.gameObject; this.m_Script = serializedObject.FindProperty("m_Script"); this.m_Motions = serializedObject.FindProperty("m_Motions"); this.m_MotionList = new ReorderableList(serializedObject, this.m_Motions, true, true, true, true) { drawHeaderCallback = new ReorderableList.HeaderCallbackDelegate(DrawMotionHeader), drawElementCallback = new ReorderableList.ElementCallbackDelegate(DrawMotion), onAddDropdownCallback = new ReorderableList.AddDropdownCallbackDelegate(AddMotion), onRemoveCallback = new ReorderableList.RemoveCallbackDelegate(RemoveMotion), onSelectCallback = new ReorderableList.SelectCallbackDelegate(SelectMotion), drawElementBackgroundCallback = new ReorderableList.ElementCallbackDelegate(DrawMotionBackground) }; int motionIndex = EditorPrefs.GetInt("MotionIndex" + target.GetInstanceID().ToString(), -1); if (this.m_MotionList.count > motionIndex) { this.m_MotionList.index = motionIndex; SelectMotion(this.m_MotionList); } MotionState[] states = this.m_Controller.GetComponents <MotionState> (); for (int i = 0; i < states.Length; i++) { states [i].hideFlags = HideFlags.HideInInspector; } this.m_NotReferencedMotions = new List <MotionState>(); for (int i = 0; i < states.Length; i++) { if (!this.m_Controller.Motions.Contains(states[i])) { this.m_NotReferencedMotions.Add(states[i]); } } for (int i = 0; i < this.m_Controller.Motions.Count; i++) { if (this.m_Controller.Motions[i] != null) { if (this.m_Controller.Motions[i].gameObject != this.m_GameObject) { if (ComponentUtility.CopyComponent(this.m_Controller.Motions[i])) { MotionState component = this.m_GameObject.AddComponent(this.m_Controller.Motions[i].GetType()) as MotionState; ComponentUtility.PasteComponentValues(component); this.m_Controller.Motions[i] = component; } } } } EditorApplication.playModeStateChanged += PlayModeState; }
private void Start() { this.m_Transform = transform.root; this.m_Animator = this.m_Transform.GetComponent <Animator> (); this.m_Rigidbody = this.m_Transform.GetComponent <Rigidbody> (); this.m_CapsuleCollider = this.m_Transform.GetComponent <CapsuleCollider> (); this.m_Camera = Camera.main.GetComponent <ThirdPersonCamera>(); ThirdPersonController[] controllers = this.m_Transform.GetComponents <ThirdPersonController> (); for (int i = 0; i < controllers.Length; i++) { if (controllers [i].enabled) { this.m_Controller = controllers [i]; } } }
public void CopyProperties(ThirdPersonController other) { this.m_DontDestroyOnLoad = other.m_DontDestroyOnLoad; this.m_ForwardInput = other.m_ForwardInput; this.m_HorizontalInput = other.m_HorizontalInput; this.m_SpeedMultiplier = other.m_SpeedMultiplier; this.m_AimType = other.m_AimType; this.m_AimInput = other.m_AimInput; this.m_AimRotation = other.m_AimRotation; this.m_RotationSpeed = other.m_RotationSpeed; this.m_AirSpeed = other.m_AirSpeed; this.m_AirDampening = other.m_AirDampening; this.m_GroundDampening = other.m_GroundDampening; this.m_StepOffset = other.m_StepOffset; this.m_SlopeLimit = other.m_SlopeLimit; this.m_GroundLayer = other.m_GroundLayer; this.m_SkinWidth = other.m_SkinWidth; this.m_IdleFriction = other.m_IdleFriction; this.m_MovementFriction = other.m_MovementFriction; this.m_StepFriction = other.m_StepFriction; this.m_AirFriction = other.m_AirFriction; this.m_ForwardDampTime = other.m_ForwardDampTime; this.m_HorizontalDampTime = other.m_HorizontalDampTime; /*this.m_LookOffset = other.m_LookOffset; * this.m_BodyWeight = other.m_BodyWeight; * this.m_HeadWeight = other.m_HeadWeight; * this.m_EyesWeight = other.m_EyesWeight; * this.m_ClampWeight = other.m_ClampWeight;*/ this.m_Motions = new List <MotionState> (); for (int i = 0; i < other.Motions.Count; i++) { MotionState motion = CopyComponent <MotionState> (other.Motions [i], gameObject); this.m_Motions.Add(motion); } }
private void SetupThirdPersonController() { ThirdPersonController controller = m_Character.GetComponent <ThirdPersonController>(); if (controller == null) { controller = m_Character.AddComponent <ThirdPersonController>(); } controller.IdleFriction = m_MaxFriction; controller.MovementFriction = m_Frictionless; controller.StepFriction = m_Frictionless; controller.AirFriction = m_Frictionless; if (!m_DefaultMotions) { return; } List <MotionState> motions = new List <MotionState>(); Swim swim = m_Character.AddComponent <Swim>(); swim.State = "Swim"; motions.Add(swim); Fall fall = m_Character.AddComponent <Fall>(); fall.State = "Fall"; fall.StartType = StartType.Automatic; fall.StopType = StopType.Manual; motions.Add(fall); ChangeHeight changeHeight = m_Character.AddComponent <ChangeHeight>(); changeHeight.State = "Crouch"; changeHeight.InputName = "Crouch"; changeHeight.StartType = StartType.Down; changeHeight.StopType = StopType.Toggle; motions.Add(changeHeight); Jump jump = m_Character.AddComponent <Jump>(); jump.State = "Jump"; jump.InputName = "Jump"; jump.StartType = StartType.Down; jump.StopType = StopType.Automatic; motions.Add(jump); Push push = m_Character.AddComponent <Push>(); push.State = "Push"; motions.Add(push); ChangeSpeed changeSpeed = m_Character.AddComponent <ChangeSpeed>(); changeSpeed.InputName = "Change Speed"; changeSpeed.StartType = StartType.Down; changeSpeed.StopType = StopType.Up; motions.Add(changeSpeed); controller.Motions = motions; }