- Home /
2.5D Platformer where character moves between points has issues where physics take player off of the line between points.
Hello all. I'm making a game that operates like a 2.5D platformer in 3D Space. The character is a rigidbody that moves between these way points that are anywhere on the x,y,z axis. The way I have the character move is I apply forces and velocity changes in the direction (The vector 3 of the point they are moving towards). However, if the player is moving towards a point and a wall/platform is in the way, now if they player just continues to run towards that wall, the rigidbody will instead slide the player off to the side of the platforms. Thus, no longer being in 2.5D space and probably falling off the level.
I've tried things like changing the physics material or making velocity 0 if a raycast detects a wall as the player is running towards a wall but that mitigates the problem and if they player sits there long enough running at the wall, they can end up falling off the level.
What might be the better way of doing this is to make sure that the player is always getting back to the nearest point of the invisible line between the 2 points. How would I begin to express this in code? Thanks in advance.