/// <summary> /// Called each frame, this rotates the camera to look at the player position. /// </summary> public void CameraLookCalculations() { //Ensure the cursor is locked to the screen if (Cursor.lockState != CursorLockMode.Locked) { if (PlayerConrollerInput.GetFireButton()) { Cursor.lockState = CursorLockMode.Locked; } } //Camera rotation stuff, mouse controls this rotX -= PlayerConrollerInput.GetVerticalMouseInput() * xMouseSensitivity * 0.02f; //rotation up and down (along the x axis) rotY += PlayerConrollerInput.GetHorizontalMouseInput() * yMouseSensitivity * 0.02f; //rotation side to side (along the y axis) //Clamp the x rotation if (rotX < -90) { rotX = -90; } else if (rotX > 90) { rotX = 90; } }
void CrouchControls() { if (PlayerConrollerInput.GetCrouchKey()) { wishCrouch = true; } else { wishCrouch = false; } }
private void HookFire() { if (PlayerConrollerInput.GetAlternativeFireButton() && !hookOn) { currentHook = Instantiate(grappleHook, anchorPosition.position, anchorPosition.rotation); //grab the hook projectile and set its andchor to the child position anchor of the player model. HookInstance hook = currentHook.GetComponent <HookInstance>(); //propel the hook forward. hook.SetHookInstance(this); hook.currentVelocity = speed * hook.transform.forward; hookOn = true; //flip the hook bool to true so that the object knows a hook exists in the world. } }
public void UseHook(Vector3 playerVelocity, float gravity, bool isGrounded) { if (canUseHook && PlayerConrollerInput.GetAlternativeFireButton()) { HookFire(); } //if the hook is latched check for other user input. if (hookIn && canUseHook) { HookControls(); //Check for user hook input HookBehavior(playerVelocity, gravity, isGrounded); //Check for hook behaviour } }
//Sets the movement direction based on player input public void SetMovementDir() { cmd.forwardMove = PlayerConrollerInput.GetVerticalMovement(); //Queue up the players forward desires for this frame using the vertical ais of the Get Axis function. cmd.rightMove = PlayerConrollerInput.GetHorizontalMovement(); //Queue up the players movement to the left or right based on the axis input of the horizontal motion. }