Hi All,
I’m working on a [game]
And I’ve got character movement working on flat land but now I’m trying to get movement working on an incline/decline.
So, I’m trying to figure out how to calculate the player’s position on the incline as they move.
The character is currently only moving on the x and z axis. The y axis is up and down.
A simple solution would be to take the player’s next x and z axis (and when I say next I mean as they’re moving, the next position they’ll be in), then create a raycaster from that next position pointing upwards, see where it collides, and then set the player’s y coordinate there. However the issue with that solution is that the player will be moving faster on an incline than on flat land. Due to the fact that they will be moving at the same speed on the x and z axis but will also be moving on the y axis which means more distance traveled in total.
So I’m trying to think of a different way to calculate the player’s position on a slope. I’m thinking I might be able to use a CircleGeometry object to detect the circle’s intersection with the slope to achieve a consistent movement speed. But as far as I know, RayCaster is the only object that can detect intersection.
Has anyone face a similar problem to this?