Raycast often failing to find things it passes through


I am using app.systems.rigidbody.raycastFirst to build a playercontroller. However, it seems that this call will often fail for find colliders which it did pass through.

Every update, I cast a ray from the player’s position at the start of the frame, to the player’s position at the end of the frame.

Debugging my script, I can see a raycast going from outside the collision volume to inside the collision volume, and yet I do not get a results callback.

However, this behaviour is inconsistent. Sometimes it detects it, and sometimes it doesn’t. I can’t seem to find a pattern, although it is starting to seem like it might be related to really small movements (eg. if I move the player slowly they can slip through raycast detection - perhaps there is a min ray length).

Here is the abridged version of my code:

    update: function (dt) {
        var startPos = this.entity.getPosition().clone();

        this.entity.translate(forwardVel.x, forwardVel.y, 0);
        if (forwardVel.y < 0) {
    _checkGround: function (start) {
        var self = this;
        app.systems.rigidbody.raycastFirst(start, this.entity.getPosition(), function (result) {

Full source: PlayCanvas | HTML5 Game Engine

Normally I would cast from above the player, or well within the volume of its collider in case you are getting effects of being just inside the ground collider. If your model is centred on the ground (between the feet for instance) you can often get that effect. Though I note you have visualised the situation and believe this isn’t happening - possibly a float inconsistency if the start of the ray is only marginally outside the collision volume.