/// <summary> /// Can the ability be started? /// </summary> /// <returns>True if the ability can be started.</returns> public override bool CanStartAbility() { // The character can move if the character is on the ground and a moveable object is near. if (m_Controller.Grounded && Physics.Raycast(m_Transform.position + m_Controller.CapsuleCollider.center, m_Transform.forward, out m_RaycastHit, m_StartMoveMaxDistance, m_MoveableLayer.value, QueryTriggerInteraction.Ignore)) { // The character must be mostly looking at the puseable object. if (Vector3.Angle(-m_RaycastHit.normal, m_Transform.forward) < m_StartMoveMaxLookAngle) { // The moveable object must have the MoveableObject component and is able to be Moveed. if ((m_MoveableObject = (m_MoveableTransform = m_RaycastHit.transform).GetComponent <MoveableObject>()) != null && m_MoveableObject.CanStartMove()) { // The closest point between the character and the Moveable object is needed in order to know how far out the character should start Moveing from. var closestPoint = m_RaycastHit.collider.ClosestPointOnBounds(m_Transform.position); m_MoveableObjectCenterOffset = ((m_RaycastHit.transform.position - closestPoint).magnitude + m_ArmLength) * m_RaycastHit.normal; m_Direction = m_RaycastHit.normal; return(true); } } } return(false); }