I have a character running straight by using AddForce. Like so:
Vector3 movement = new Vector3(0, 0, +100); rb.AddForce(movement * speed);
This is inside a fixed update and makes the player run straight. I then have a function that gets called when a player swipes the screen to move the character to the left or right. The following is how the character moves to the left.
Vector3 move = new Vector3(Myplayer.transform.position.x - movementDistance, 0, 0); rb.AddRelativeForce((move * movementSpeed) * Time.fixedDeltaTime, ForceMode.Force);
When I swipe, the player then teleport to the side instead of moving to the side smoothly while it is moving forward from the update function. The character has a running animation from Mixamo and has root motion applied with animate physics.
I tried using rigidbody.velocity and had the same issue. Is there a better way to do this to move the character horizontally to the left or right while it is already running(while still using rigidbody instead of character controller). Any help would be appreciated. Thanks in advance.