private int GetHoming() { Vector2 pos = target.localPosition - stateParent.transform.localPosition; PolarCoordinates pol = new PolarCoordinates { direction = stateParent.baseParameter.moveParameter.direction, speed = 1 }; Vector2 normal = pol.ConvertToPolar(); float cross = normal.Ccw(pos); return cross > 0 ? (int)homingLevel : -(int)homingLevel; }
private int GetHoming() { Vector2 pos = target.localPosition - stateParent.transform.localPosition; PolarCoordinates pol = new PolarCoordinates { direction = stateParent.baseParameter.moveParameter.direction, speed = 1 }; Vector2 normal = pol.ConvertToPolar(); float cross = normal.Ccw(pos); return(cross > 0 ? (int)homingLevel : -(int)homingLevel); }
/// <summary> /// 自分の向いてる方向にBoxがあったら返す。 /// </summary> /// <returns></returns> protected BaseBox GetNearBox() { //向いてる方向のレイを作る Ray r = new Ray(transform.position, PolarCoordinates.ConvertToPolar(frontDirection, 1F)); RaycastHit h = new RaycastHit(); //目の前に箱があった場合 if (Physics.Raycast(r, out h, 0.05F)) { var script = h.collider.gameObject.GetComponent <BaseBox>(); return(script is BaseBox ? script : null); } return(null); }
/// <summary> /// 速度情報の計算を行う; /// speed, directionのどちらかのsetterが呼ばれたときにフックされる /// </summary> private void Caluclate() { velocity = m_polar.ConvertToPolar(); }