开发者

How to make the player slide smoothly against terrain in a game?

开发者 https://www.devze.com 2023-01-17 21:15 出处:网络
I\'m making an isometric game. When the player tries to walk diagonally into a wall I want them to slide smoothly across it, so whate开发者_如何学运维ver portion of the movement would be legal is us

How to make the player slide smoothly against terrain in a game?

I'm making an isometric game. When the player tries to walk diagonally into a wall I want them to slide smoothly across it, so whate开发者_如何学运维ver portion of the movement would be legal is used, and anything in the direction of the normal is thrown away. Walls can be any angle, not just vertical or horizontal, and the player has 360 motion.

I feel like I'm almost there but I can't put the last piece into place.


I believe what you want to do is project the input direction parallel to the wall.

Vector Projection would be the way to do this.

Example, when you detect collision with the wall, check the projection vector of the input along the parallel vector to the wall. If it is non-zero, replace the input vector with the projected vector.

0

精彩评论

暂无评论...
验证码 换一张
取 消