void Do_Rotation() { float rotate_speed = m_manager.Get_Rotate_Speed(); float rotation_req = 0; float curr_ch = Custom_Math_Utils.nfmod(m_body.transform.rotation.eulerAngles.y, 360); if (m_input.Get_Requested_Magnitude() > 0) { rotation_req = m_input.Get_Requested_Rotation() - curr_ch; rotation_req = (Mathf.Abs(rotation_req) > 180) ? ((rotation_req > 0) ? (360 - Mathf.Abs(rotation_req)) * -1 : (360 - Mathf.Abs(rotation_req))) : rotation_req; rotation_req = (Mathf.Abs(rotation_req) > rotate_speed) ? ((rotation_req > 0) ? rotate_speed : (rotation_req < 0) ? -rotate_speed : 0) : rotation_req; } m_body.transform.Rotate(new Vector3(0.0f, rotation_req, 0.0f)); }
public override float Get_Requested_Rotation() { // Return the current rotation of the joystick float Joystick_X = state.ThumbSticks.Left.X; float Joystick_Y = state.ThumbSticks.Left.Y; float ret = 0.0f; if ((Joystick_X != 0) || (Joystick_Y != 0)) { ret = (Custom_Math_Utils.nfmod(-(((Mathf.Atan2(Joystick_Y, Joystick_X)) * Mathf.Rad2Deg) - 90), 360)); ret = (ret < 0) ? ret + 360 : ret; } return(ret); }
public override float Get_Requested_Rotation() { float ret = 0.0f; Check_Pathing(); if (m_target != null) { try { Vector3 node_target = m_Path.Current_Point().m_Position.transform.position; Vector3 my_pos = m_Manager.Get_Position(); float Joystick_X = node_target.x - my_pos.x; float Joystick_Y = node_target.z - my_pos.z; if ((Joystick_X != 0) || (Joystick_Y != 0)) { ret = (Custom_Math_Utils.nfmod(-(((Mathf.Atan2(Joystick_Y, Joystick_X)) * Mathf.Rad2Deg) - 90), 360)); ret = (ret < 0) ? ret + 360 : ret; } } catch { Check_Pathing(); } } return(ret); }
public override float Get_Requested_Rotation() { float ret = 0.0f; Vector3 my_pos = m_Manager.Get_Position(); float Joystick_X = 0; float Joystick_Y = 0; switch (m_State) { case Security_State.Patrol: { try { Vector3 node_target = m_Path.Current_Point().m_Position.transform.position; Joystick_X = node_target.x - my_pos.x; Joystick_Y = node_target.z - my_pos.z; } catch { Check_Pathing(); } break; } case Security_State.Catch: { try { if (m_Target_Item != null) { Joystick_X = m_Target_Item.transform.position.x - my_pos.x; Joystick_Y = m_Target_Item.transform.position.z - my_pos.z; } else { if (m_ItemVision.NeedToCatch()) { m_Target_Item = m_ItemVision.Get_Best_Item(); } } } catch { Debug.Log("State: CATCH || Rotation Calculation"); } break; } case Security_State.Chase: { try { Vector3 node_target = m_Path.Current_Point().m_Position.transform.position; Joystick_X = node_target.x - my_pos.x; Joystick_Y = node_target.z - my_pos.z; } catch { Check_Pathing(); } break; } case Security_State.Attack: { try { if (m_Enemy_Agent != null && m_Enemy_Position != null) { Joystick_X = m_Enemy_Position.position.x - my_pos.x; Joystick_Y = m_Enemy_Position.position.z - my_pos.z; } else { if (m_Last_Collided_Agent != null) { m_Enemy_Agent = m_Last_Collided_Agent; m_Enemy_Position = m_Enemy_Agent.Get_Object().transform; m_Last_Collided_Agent = null; } else if (m_Last_Collided_Item != null) { m_Enemy_Agent = m_Last_Collided_Item.prev_owner; m_Enemy_Position = m_Enemy_Agent.Get_Object().transform; m_Last_Collided_Item = null; } } } catch { Debug.Log("State: ATTACK || Rotation Calculation"); } break; } } if ((Joystick_X != 0) || (Joystick_Y != 0)) { ret = (Custom_Math_Utils.nfmod(-(((Mathf.Atan2(Joystick_Y, Joystick_X)) * Mathf.Rad2Deg) - 90), 360)); ret = (ret < 0) ? ret + 360 : ret; } return(ret); }