I’m making an endless runner game and I made a script that makes the ground move faster as time goes, so to make it so the player will move as fast as the ground does i got the speed of the ground from the ground script
rb = this.GetComponent<Rigidbody2D>();
playerSpeed = GameObject.FindObjectOfType<MovingFloor>().groundVelocity;
if(isTouchingObstacle)
{
rb.velocity = new Vector2(-playerSpeed, 0);
}
i found that if i set the second float in rb.velocity it will change the gravity, but it will instantly push me down instead of keeping the momentum that I had before i died if that makes any sense