/// <summary> /// 苗を置く候補座標を返します。 /// </summary> /// <param name="stellaPosition">ステラの座標</param> /// <returns>求めた苗の座標</returns> Vector3 GetPutPosition(Vector3 stellaPosition) { Vector3 naepos = stellaPosition; float absOffset = StellaMove.ActionBoxInstance.colliderCenter.x + StellaMove.ActionBoxInstance.halfExtents.x + StellaMove.naeActable.ColliderExtentsX; float baseX = naepos.x + absOffset * StellaMove.forwardVector.x; // 単位変換 naepos.x = Mathf.Round(baseX / naeUnit) * naeUnit; if (absOffset < (Mathf.Abs(naepos.x - stellaPosition.x))) { // 遠くなっているので、1単位近づける naepos.x -= naeUnit * StellaMove.forwardVector.x; } // 床の位置を調べる naepos.y = StellaMove.chrController.bounds.center.y; int grobj = PhysicsCaster.GetGround(naepos, float.PositiveInfinity); if (grobj == -1) { // 置けない高さを設定 naepos.y = (StellaMove.chrController.bounds.min.y - naePutUnderHeight * 2f); return(naepos); } naepos.y = PhysicsCaster.hits[grobj].collider.bounds.max.y; return(naepos); }
/// <summary> /// 上下キーが押されていて、ツタと重なっていたら、そのツタのインスタンスを返します。 /// </summary> /// <returns></returns> public static bool CheckIvyHold() { float v = Input.GetAxisRaw("Vertical"); // 上下キーが押されていなければなし if (Mathf.Approximately(v, 0f)) { return(false); } if (v < -0.5f) { // 下キーの時は、着地していたら移行無し Vector3 foot = chrController.bounds.center; foot.y = chrController.bounds.min.y; int goidx = PhysicsCaster.GetGround(foot, 0.1f); if (goidx != -1) { return(false); } } IvyInstance = CheckIvyOverlap(); if (IvyInstance == null) { return(false); } if (IsIvyUp()) { return(IvyInstance.Hold()); } return(false); }