I am making a runner type game. Right now my ground goes forward one tile in front of the other. I move my character too far to the right or left and I will fall off. How do I create a ground based on my players position so that my character never falls off?
Hello, that depends a bit on the type of game and what features should be included.
The solution you are asking for would be to always set the position of the tarpaulin to the position of the player, e.g. like this:
plane.position = new Vector3(player.position.x, 0, player.position.z)
But I doubt that is the best solution and will probably bring some other problems later.
If you e.g. always run on the same level, then you could generally do without ground physics and manage the player’s rigidbody without gravity and only trigger detections.
Another way would be not to move the player in an endless level, but to slide the level past the player.
If you just want some prototypes quickly, then you can of course also use a very large tarpaulin. (you can scale the collider independently of the mesh if you care about the optics)
Depending on what kind of game you have in mind, the solution will look different.