public void shoot(LorR Hand) { if (Hand == LorR.LeftHand) { if (OVRInput.GetDown(OVRInput.RawButton.LIndexTrigger)) { flag = true; } if (flag) { cell.GetComponent <Cell>().shoot(); } if (OVRInput.GetUp(OVRInput.RawButton.LIndexTrigger)) { flag = false; } } else { if (OVRInput.GetDown(OVRInput.RawButton.RIndexTrigger)) { flag2 = true; } if (flag2) { cell.GetComponent <Cell>().shoot(); } if (OVRInput.GetUp(OVRInput.RawButton.RIndexTrigger)) { flag2 = false; } } }
//デバック用 /*void Start(){ * Run(Position.Middle); * }*/ public void Run(Position pos) { position = pos; rb = GetComponent <Rigidbody2D>(); //加える力 RandomForce(ref forcex, ref forcey); Vector2 force = new Vector2(forcex, forcey); //速度に合わせて画像を回転させる if (forcex > 0) { direct = LorR.Right; } else if (forcex < 0) { direct = LorR.Left; } else { if (Random.value > 0.5f) { direct = LorR.Right; } } //Rigidbody2Dに力を加える rb.AddForce(force); on = true; }