Skip to content

Tunneling problem with CCD enabled bodies #286

Open
@double-hash

Description

@double-hash

Hello ! I'm encoutering a problem with my objects/bodies. I'm working on JS 3D video-game which takes place in space (so no gravity) but it isn't a space simulation. More like an arcade video game.

So, the player controls a space ship (third person view) and can fire lasers (they are small boxes geometry which are going pretty fast), I enabled CCD on both bodies (spaceship and each laser body/collider). But when a player fires lasers on another player's spaceship at a certain angle, we can experiment tunneling.

video_illustrating_tunneling.mp4

I thought at first time it was because the lasers are moving really fast (like X-wings lasers in star wars movies) or because the spaceship collider geometry isn't clean, so maybe some faces of the model are glitching (it was a TriMesh).

So I tried several things:

  • added a RayCast on my laser firing so a ray testing is performed each step, on each laser, to know if a collider collide or will collide the laser pretty soon ( => the system worked but I experienced tunneling too)
  • modified my spaceship collider (custom) geometry to something more simple, less complex, even tested a relatively thick cuboid geometry
  • Lowered the lasers' speed to determine if the tunneling is related to it ( => it is, because I experience a lot less tunneling with low speed, but it's not the feeling I want).
  • modified my lasers collider geometry to make it a little bigger
  • set my bodies to setCanSleep(false) because it can happen when a spaceship isn't moving, so I thought maybe it was because of Sleeping mode
  • tried to edit IntegrationParameters.maxCcdSubsteps to increase it but didn't work I think ? Or at least I didn't notice changes in my problem

But nothing significant or relevant to fix the tunneling problem with all this.

Few things to note :

  • My laser colliders are set to sensor and the bodies to KinematicVelocityBased with CCD enabled;
  • My spaceship body is set to dynamic (and I control its translation with its velocity, it's not very clean but it do the job)
  • It's a multiplayer game so my physic engine is server-side and graphics engine is only client-side.

I don't really know what to do now. I will try to update this issue with a simplified version of my project I can share with you, if you're interested to help me. But if you already have some clues, especially with the IntegrationParameters.maxCcdSubsteps parameter which doesn't seem to change collision accuracy, feel free to share your thoughts :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions