best way to write physics,detection in games
best way to write physics,detection in games
Friday, August 2, 2019 - 06:13
especially games that can wallrun, slide along edges, one that especially do not cause clip in or fallthrough floors,
and maybe efficient byte sizes? maybe like this...
https://www.youtube.com/watch?v=xwcM_7yMygc
or this, where it detects wall without facing it.
https://www.youtube.com/watch?v=X3bxZnvQ1AE
help?
Let me preface by saying there are several ways to go about physics like this, and many cases are going to require their own unique implementation.
If you don't absolutely HAVE to write your physics engine from scratch, I would highly advise an engine such as Bullet physics, depending on your language. I know Bullet has ports to C++, Java, Python, and JavaScript, and I wouldn't doubt if there were more. I use Bullet on my 3D java projects and it is an incredibly powerful tool.
Now, as for the specific methods of achieving what you posted for wall running, a few potential options could be:
An alternative is to have different movement functions for your character (e.g. walking, freefall, in water, climbing a ladder, wallrun, etc.) that are called each frame by a master function that checks whether the character is on the ground, hugging a wall, and so on, where the standard gravity applies only in some of these functions. The old Quake 3 Arena used to work this way; its collision detection is very robust - no objects clip through walls, no matter how small and fast, and, if you're working with a simpler engine or want to code the physics/collision detection from scratch it may be of inspiration.