i’m making an endless runner game and the floor’s velocity slightly increases as time goes, i tried to make it so when the player gets eliminated he will move as fast as the floor does because he will no longer be sprinting but when i do that it disables the gravity after the player gets eliminated
in the following script I made it so when you touch an obstacle you will move as fast as the ground does by getting the float from the ground script into the player script, i did try changing the second float in rb.velocity
but it seems to just pull me to the ground without keeping my momentum
rb = this.GetComponent<Rigidbody2D>();
playerSpeed = GameObject.FindObjectOfType<MovingFloor>().groundVelocity;
if(isTouchingObstacle)
{
rb.velocity = new Vector2(-playerSpeed, 0);
}
hope that made sense