Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
Fixing ghost collisions on a plane made of multiple Colliders?

Basic Problem: Unity's physics engine produces weird collisions when a player is moving over a flat surface made of more than one Collider. The ghost collisions occur at the joints between Colliders, and express as two behaviors:

The player is moving left to right when the collision occurs

This seems to be a problem with physics engines in general, based on this talk by Bennett Foddy:

https://www.youtube.com/watch?v=NwPIoVW65pE&ab_channel=GDC

Game Specifics: In my case, the player is moving through a procedurally generated wormhole, composed of Segment objects using a MeshCollider. The wormhole twists randomly through 3D space, while the width and height change dynamically. The player can strafe 360 degrees around the inside of the tunnel (direction of gravity is relative to position).

This makes the simpler solutions I've found impractical. Those include:

  1. Using a single object instead of many
  2. Placing redundant Colliders behind the joints

I've managed to flag these erroneous collisions in OnCollisionEnter(). This method on the PlayerController works fine to identify these erroneous collisions, and raise a flag.

private void OnCollisionEnter(Collision other)
{
    if (other.gameObject.tag != "Tunnel"){return;}

    // Bit mask for tunnel layer.
    int tunnelLayerMask = 1 << 10;

    // Get the direction from the nearest Segment's origin to the collision point.
    Vector3 toCollision = other.contacts[0].point - nearestSegment.transform.position;
 
    if (Physics.Raycast(nearestSegment.transform.position, toCollision, out RaycastHit hit, 100f, tunnelLayerMask))
    {
        // Flag the collision if the detected surface normal 
        // isn't equal to the collision normal.
        if (other.contacts[0].normal != hit.normal) { colFidelityFlag = true; }
    }
}

But I'm at a complete loss when it comes to gracefully resolving the issue.

Currently, I'm just caching the player's velocity each frame. If a collision is flagged, I overwrite the resulting velocity with the cached velocity from the previous frame. This works for most conditions: the player ghosts imperceptibly into the floor for a frame, and gets past the offending joint. But under high enough velocities or interactions with obstacles inside the tunnel, it is possible for the player to be ejected through the floor, and into space. I don't want to limit the velocity of the player too much, since the feel of the game partially relies on high velocity and hard collisions.

Does anyone know of a better way to resolve these erroneous collisions?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This is called "ghost vertices", and happens if you have like 2 box colliders (or something equivalent) and they are connected to each other. You could try to join the colliders so that instead of 2 separate connected colliders you have a single one.

Here ghost vertices are explained in more detail: https://www.iforce2d.net/b2dtut/ghost-vertices

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda