Monday, July 18, 2022
HomeGame DevelopmentRepair wall glitching in capaule to octree collision JavaScript?

Repair wall glitching in capaule to octree collision JavaScript?


BH

Within the three.js instance for a primary particular person sport https://threejs.org/examples/?q=sport#games_fps you need to discover that on the corners it will get caught, seemingly as a result of it collides with one facet, then pushes it into the opposite facet (when there’s lower than a 90 diploma angle) then that facet pushes it again into the primary facet, and if one retains making an attempt to maneuver this course of retains getting repeated.

The related a part of the collision is https://github.com/mrdoob/three.js/blob/dev/examples/games_fps.html

    perform playerCollisions() {

                const outcome = worldOctree.capsuleIntersect( playerCollider );

                playerOnFloor = false;

                if ( outcome ) {

                    playerOnFloor = outcome.regular.y > 0;

                    if ( ! playerOnFloor ) {

                        playerVelocity.addScaledVector( outcome.regular, - outcome.regular.dot( playerVelocity ) );

                    }

                    playerCollider.translate( outcome.regular.multiplyScalar( outcome.depth ) );

                }

            }

First simply checks if it is on the bottom (and if not then makes it fall down alongside the wall it is colliding it, or a minimum of that is what I believe it does) then slides it the wrong way of no matter it collides with, which seemingly is what’s inflicting the jitter because it’s simply pushing it into the opposite wall when it is at an acute angle.

I attempted tweaking with it however do not know what to do or easy methods to begin, any concepts?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments