OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Octree not detecting collisons with objects that are at a 90deg angle to the floor

  • Thread starter Thread starter NadiaAli00098
  • Start date Start date
N

NadiaAli00098

Guest
A collision with any object that is not 90deg from the floor it detects but when I have for example a border or a cube in the scene it just goes straight through the mesh. The floor works fine.

Code:
 playerCollisions() {
        const result = this.octree.capsuleIntersect(this.player.collider);
        this.player.onFloor = false;
    
        if (result) {
         
            this.player.onFloor = result.normal.y > 0;
    
            if (!this.player.onFloor) {
          
                const velocityProjection = result.normal.dot(this.player.velocity);
                this.player.velocity.addScaledVector(result.normal, -velocityProjection);
            }
    
            // Translate the player's collider out of the collision
            this.player.collider.translate(result.normal.multiplyScalar(result.depth));

also sometimes it goes through once and if I move the player back and forth the second time it registers the collision.

<p>A collision with any object that is not 90deg from the floor it detects but when I have for example a border or a cube in the scene it just goes straight through the mesh. The floor works fine.</p>
<pre><code> playerCollisions() {
const result = this.octree.capsuleIntersect(this.player.collider);
this.player.onFloor = false;

if (result) {

this.player.onFloor = result.normal.y > 0;

if (!this.player.onFloor) {

const velocityProjection = result.normal.dot(this.player.velocity);
this.player.velocity.addScaledVector(result.normal, -velocityProjection);
}

// Translate the player's collider out of the collision
this.player.collider.translate(result.normal.multiplyScalar(result.depth));
</code></pre>
<p>also sometimes it goes through once and if I move the player back and forth the second time it registers the collision.</p>
 

Latest posts

Top