public void UpdatePosition() { if (!IsInteracting) { Vector3 newPosition; if (MovementInputValue == Vector3.zero) { return; } else { float distanceToSling = Vector3.Distance(PlayerRigidbody.position, _slingshotPos); // If user go backward / to the side, use backward curve to go slower and slower if (MovementInputValue.z < 0.0f) //TODO IsGoingTowardTheSide() { newPosition = CalculateNewPosition(_slingshotSettings.SlingshotWalkBackwardCurve, distanceToSling); } // If user go forward / toward the center, use forward curve to go faster else { newPosition = CalculateNewPosition(_slingshotSettings.SlingshotWalkForwardCurve, distanceToSling); } distanceToSling = Vector3.Distance(newPosition, _slingshotPos); if (NewPositionIsValid(distanceToSling)) { PlayerRigidbody.MovePosition(newPosition); } } } }
public void UpdatePosition() { if (!IsInteracting) { Vector3 newPosition = PlayerRigidbody.position + Time.deltaTime * MovementInputValue; PlayerRigidbody.MovePosition(newPosition); } }
/* * Movement controls of the player */ public void MovementControl() { Movement = new Vector3(LeftJoystick.Horizontal, 0f, LeftJoystick.Vertical).normalized *Speed *Time.deltaTime; PlayerRigidbody.MovePosition(PlayerTransform.position + Movement); PlayerRigidbody.MoveRotation(Quaternion.LookRotation(new Vector3(LeftJoystick.Horizontal, 0f, LeftJoystick.Vertical))); }