I am trying to handle gravitational effect on my player project (while on an inclined plane) without using a dedicated Physics engine.
The reason behind my decision has something to do with the issues I encountered while trying to use Cannon JS.
I am now using
moveWithCollisions to avoid walking through solid objects (that have
checkCollisions set to
true). However, that will also result in my player slowly sliding down any inclined plane while standing still.
My plan is to use Ray cast every frame to detect any ground underneath the player.
If none is detected, the player will “fall”.
If ground is detected, I want to find the angle of incidence of the ray with the intercepting mesh. If the angle is lesser than a certain limit (say 15 degrees), my player won’t slide (I’ll set the gravity vector for that frame to 0).
Problem is that I cannot seem to find out the angle of incidence (angle at which the ray hits mesh) during ray cast hit. Googling did not help.
Can someone please guide me in this regard?
Also, what do you think of my plan to fake the physics part in this manner?