// Update is called once per frame void Update() { #if ENABLE_LEGACY_INPUT_MANAGER Vector3 input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); if (input.magnitude > 0) { input = Camera.main.transform.rotation * input; if (input.magnitude > 0.001f) { transform.position += input * (speed * Time.deltaTime); if (rotatePlayer) { float t = Cinemachine.Utility.Damper.Damp(1, rotationDamping, Time.deltaTime); Quaternion newRotation = Quaternion.LookRotation(input.normalized, transform.up); transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, t); } } } // Stick to sphere surface if (Sphere != null) { var up = transform.position - Sphere.transform.position; up = up.normalized; var fwd = transform.forward.ProjectOntoPlane(up); transform.position = Sphere.transform.position + up * (Sphere.radius + transform.localScale.y / 2); transform.rotation = Quaternion.LookRotation(fwd, up); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void Update() { #if ENABLE_LEGACY_INPUT_MANAGER if (Input.GetKey("w")) { transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementSpeed; } else if (Input.GetKey("s")) { transform.position -= transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementSpeed; } if (Input.GetKey("a") && !Input.GetKey("d")) { transform.position += transform.TransformDirection(Vector3.left) * Time.deltaTime * movementSpeed; } else if (Input.GetKey("d") && !Input.GetKey("a")) { transform.position -= transform.TransformDirection(Vector3.left) * Time.deltaTime * movementSpeed; } //mouse look at float horizontal = Input.GetAxis("Mouse X") * lookatspeed; float vertical = Input.GetAxis("Mouse Y") * lookatspeed; transform.Rotate(0f, horizontal, 0f, Space.World); //transform.Rotate(-vertical, 0f, 0f, Space.Self); #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void Update() { #if ENABLE_LEGACY_INPUT_MANAGER if (vcam != null) { if (Input.GetKey(ActivationKey)) { if (!boosted) { vcam.Priority += PriorityBoostAmount; boosted = true; } } else if (boosted) { vcam.Priority -= PriorityBoostAmount; boosted = false; } } if (Reticle != null) { Reticle.SetActive(boosted); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void Update() { #if ENABLE_LEGACY_INPUT_MANAGER float zoom = m_VirtualCamera.m_Lens.OrthographicSize + Input.mouseScrollDelta.y * ZoomMultiplier; m_VirtualCamera.m_Lens.OrthographicSize = Mathf.Clamp(zoom, MinZoom, MaxZoom); #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
// Update is called once per frame void FixedUpdate() { #if ENABLE_LEGACY_INPUT_MANAGER input.x = Input.GetAxis("Horizontal"); input.y = Input.GetAxis("Vertical"); // set speed to both vertical and horizontal inputs if (useCharacterForward) { speed = Mathf.Abs(input.x) + input.y; } else { speed = Mathf.Abs(input.x) + Mathf.Abs(input.y); } speed = Mathf.Clamp(speed, 0f, 1f); speed = Mathf.SmoothDamp(anim.GetFloat("Speed"), speed, ref velocity, 0.1f); anim.SetFloat("Speed", speed); if (input.y < 0f && useCharacterForward) { direction = input.y; } else { direction = 0f; } anim.SetFloat("Direction", direction); // set sprinting isSprinting = ((Input.GetKey(sprintJoystick) || Input.GetKey(sprintKeyboard)) && input != Vector2.zero && direction >= 0f); anim.SetBool("isSprinting", isSprinting); // Update target direction relative to the camera view (or not if the Keep Direction option is checked) UpdateTargetDirection(); if (input != Vector2.zero && targetDirection.magnitude > 0.1f) { Vector3 lookDirection = targetDirection.normalized; freeRotation = Quaternion.LookRotation(lookDirection, transform.up); var diferenceRotation = freeRotation.eulerAngles.y - transform.eulerAngles.y; var eulerY = transform.eulerAngles.y; if (diferenceRotation < 0 || diferenceRotation > 0) { eulerY = freeRotation.eulerAngles.y; } var euler = new Vector3(0, eulerY, 0); transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(euler), turnSpeed * turnSpeedMultiplier * Time.deltaTime); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void Update() { #if ENABLE_LEGACY_INPUT_MANAGER float horizontal = Input.GetAxis("Mouse X") * speed; float vertical = Input.GetAxis("Mouse Y") * speed; transform.Rotate(0f, horizontal, 0f, Space.World); transform.Rotate(-vertical, 0f, 0f, Space.Self); #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
private void Update() { #if ENABLE_LEGACY_INPUT_MANAGER // Jump if ((Input.GetKeyDown(jumpJoystick) || Input.GetKeyDown(jumpKeyboard))) { rigbody.AddForce(new Vector3(0, jumpVelocity, 0), ForceMode.Impulse); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void FixedUpdate() { #if ENABLE_LEGACY_INPUT_MANAGER Vector3 input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); //input = Vector3.forward; if (input.magnitude > 0) { Vector3 fwd = worldDirection ? Vector3.forward : transform.position - Camera.main.transform.position; fwd.y = 0; fwd = fwd.normalized; if (fwd.magnitude > 0.001f) { Quaternion inputFrame = Quaternion.LookRotation(fwd, Vector3.up); input = inputFrame * input; if (input.magnitude > 0.001f) { rb.AddForce(speed * input); if (rotatePlayer) { transform.rotation = Quaternion.LookRotation(input.normalized, Vector3.up); } } } } if (Input.GetKeyDown(KeyCode.Space) && spaceAction != null) { spaceAction(); } if (Input.GetKeyDown(KeyCode.Return) && enterAction != null) { enterAction(); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }
void Update() { #if ENABLE_LEGACY_INPUT_MANAGER Vector3 fwd; switch (InputForward) { case ForwardMode.Camera: fwd = Camera.main.transform.forward; break; case ForwardMode.Player: fwd = transform.forward; break; case ForwardMode.World: default: fwd = Vector3.forward; break; } fwd.y = 0; fwd = fwd.normalized; if (fwd.sqrMagnitude < 0.01f) { return; } Quaternion inputFrame = Quaternion.LookRotation(fwd, Vector3.up); Vector3 input = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); input = inputFrame * input; var dt = Time.deltaTime; var desiredVelocity = input * Speed; var deltaVel = desiredVelocity - m_currentVleocity; m_currentVleocity += Damper.Damp(deltaVel, VelocityDamping, dt); transform.position += m_currentVleocity * dt; if (RotatePlayer && m_currentVleocity.sqrMagnitude > 0.01f) { var qA = transform.rotation; var qB = Quaternion.LookRotation( (InputForward == ForwardMode.Player && Vector3.Dot(fwd, m_currentVleocity) < 0) ? -m_currentVleocity : m_currentVleocity); transform.rotation = Quaternion.Slerp(qA, qB, Damper.Damp(1, VelocityDamping, dt)); } // Process jump if (m_currentJumpSpeed != 0) { m_currentJumpSpeed -= 10 * dt; } var p = transform.position; p.y += m_currentJumpSpeed * dt; if (p.y < m_restY) { p.y = m_restY; m_currentJumpSpeed = 0; } transform.position = p; if (Input.GetKeyDown(KeyCode.Space) && SpaceAction != null) { SpaceAction(); } if (Input.GetKeyDown(KeyCode.Return) && EnterAction != null) { EnterAction(); } #else InputSystemHelper.EnableBackendsWarningMessage(); #endif }