/// <summary> /// 移動 /// </summary> void Move() { //入力を受け付けない if (ballBehaviour.cantInputTime > 0.0f) { ballBehaviour.cantInputTime -= Time.deltaTime; return; } var stickInput = SwitchInput.GetStick(ballBehaviour.playerIndex); Vector3 addPower = new Vector3(stickInput.x, 0, stickInput.y); //力を加える AddForceAndTorque(addPower); //向きを更新 ballBehaviour.UpdateLookatDirection(addPower); //アニメーションの更新 if (stickInput.sqrMagnitude == 0) { ballBehaviour.playerAnimationController.AnimationSwitch(PlayerAnimationController.AnimationType.Idle); } else { if (stickInput.magnitude > 0.9f) { ballBehaviour.playerAnimationController.AnimationSwitch(PlayerAnimationController.AnimationType.Run); } else { ballBehaviour.playerAnimationController.AnimationSwitch(PlayerAnimationController.AnimationType.Walk); } } ballBehaviour.PlayerRotation(ballBehaviour.lookatDir); }
/// <summary> /// カーソルの移動 /// </summary> /// <param name="playerId"></param> void CursorMove(int playerId) { const float cursorSpeed = 1.5f; var stick = SwitchInput.GetStick(playerId) * cursorSpeed * Time.deltaTime; Vector3 cursorPos = playerUI[playerId].cursor.transform.position; playerUI[playerId].cursor.transform.position = new Vector3( Mathf.Clamp(cursorPos.x + stick.x, viewportMin.x, viewportMax.x), Mathf.Clamp(cursorPos.y + stick.y, viewportMin.y, viewportMax.y), cursorPos.z); PointerRaycast(playerId); }