I'm working on a small project while taking a break from my bigger project and I ran into a problem of having the character jump side to side. I want to try to make an endless runner type game like a mix of temple run and geometry dash where the player is running down a path with obstacles and can either be in the center of the lane, the left or the right. The problem i'm having is I was the player to be able to move between the three spots. Left, center, or right. But i'm not trying to have the player just appear in the new positions I would like for the gameobject to slide or move there. If anyone is able to help I would greatly appreciate it. Ex. I'm not trying to us transform.translate and set the position because it just appears in the spot. I would like the user to press a button and the player slides to a set destination
i can´t try it atm, but shouldn´t it work with something like that: Code (CSharp): float movementSpeed = 2; if (Input.GetKey(KeyCode.RightArrow)) { float centerRight; // Set here the mid of your right side Vector3 newPosition = new Vector3(transform.postion.x, centerRight, transform.postion.z); // Check if the palyer is already on the right side if (transform.position.y != centerRight) // Move your player to the center of the rifht side transform.postion = Vector3.Lerp(transform.postion, newPosition, Time.deltaTime * movementSpeed); } And the same for the left side.
I would start a coroutine when you detect the player input. Inside the coroutine, do the movement over the course of multiple frames using yield return null in a loop.