/// <summary> /// プレイヤー操作をうけた移動 /// </summary> void PCMove(KeyManagerHub Key) { Vector3 stickVel = -Key.GetStickVectorFromNormal(true, CurrentCollisionNormal_Up, reverseFlag); float stickLen = stickVel.magnitude; bool key_Balling = Key.GetKey(KeyMode.Stay, Key_Hub.L2); bool key_Jump = Key.GetKey(KeyMode.Enter, Key_Hub.R2); bool key_JumpStay = Key.GetKey(KeyMode.Stay, Key_Hub.R2); bool key_Aim = Key.GetKey(KeyMode.Stay, Key_Hub.L1); bool key_Attack = Key.GetKey(KeyMode.Stay, Key_Hub.R1); bool key_Dash = Key.GetKey(KeyMode.Stay, Key_Hub.L3); bool key_Squat = Key.GetKey(KeyMode.Enter, Key_Hub.R3); if (key_Squat) { isSquat = !isSquat; } squatWeight += Time.deltaTime * (isSquat ? 2f : -2f); squatWeight = Mathf.Clamp(squatWeight, 0f, 1f); bool notDashFlag = key_Aim; if (notDashFlag) { isDash = false; } if (isDash) { isSquat = false; } //さかさま判定 if (stickLen <= 0f) { reverseFlag = CurrentCollisionNormal_Up.y < 0f ? true:false; } if (CurrentCollisionNormal_Up.y > 0f) { reverseFlag = false; } rb.freezeRotation = false; rb.angularDrag = DragState_Angler.min; rb.useGravity = true; if (key_Balling)//ボール状態 { wireManager.ResetFuck(); if (key_JumpStay) { rb.freezeRotation = true; } rb.drag = DragState.min; col.material = BallingPhysic; } else //通常状態 { JumpAction(key_Jump); if (wireManager.isFuck) { isDash = true; rb.useGravity = false; } if (IsCollision) { rb.useGravity = false; if (!isGround) { isDash = false; } else if (stickLen <= Mathf.Epsilon) { stickVel = Vector3.zero; rb.angularDrag = DragState_Angler.max; } if (stickLen < 0.9f) { isDash = false; } rb.drag = DragState.max; if (key_Dash && !notDashFlag) { isDash = true; } col.material = HumanPhysic; } else { col.material = IcePhysic; rb.drag = DragState.min; stickVel *= 0.15f; isDash = false; } currentVector = stickVel; if (stickVel.magnitude > 0f) { LastVector = stickVel; } rb.AddForce(stickVel * Time.deltaTime * moveSpeed * (isDash ? 1f : 0.5f)); } Color debCol = isGround ? Color.red : Color.green; Debug.DrawLine(rb.position, rb.position + (CurrentCollisionNormal_Up * 3f), debCol); Debug.DrawLine(rb.position, rb.position + (LastCollisionNormal_Up * 3f), debCol); if (groundRecastTimer > 0f) { groundRecastTimer -= Time.deltaTime; } }