DontGoThroughThings getting stuck in other colliders

I’m using DontGoThroughThings script on my fast moving rigidbody projectiles. This pretty much solves the problem with projectiles going through walls etc.

Sometimes though, the projectile just gets stuck in some collider it hit (projectile itself has BoxCollider, problematic target collider is usually BoxCollider/MeshCollider) and as soon as I disable the DontGoThroughThings component on the projectile, it just starts moving again, but without registering the collision obviously.

I tried playing with various physics settings, but with no luck so far.
My best bet was that penetration toleration is trolling me, but playing with ‘Default Contact Offset’ physics setting did not help.

My current Unity version is 5.5.0p1

Any help would be greatly appretiated.

Thanks,
Steven

I used DontGoThroughThings on projectiles also but as you described there was problems with the rigidbody sometimes got stuck and even bounced of other surfaces, so I made a modified version not using a rigidbody on the projectile.

Here is the code, (I haven’t tried it in a long time so no guaranties that it works.)

Also make sure the projectile is on a layer that is not included in the layermask var.

using UnityEngine;

public class ProjectileFast : MonoBehaviour
{
    [SerializeField]
    private LayerMask _layerMask;

    [SerializeField]
    private float _velocity;

    private Vector3 _previousPosition;
    private Vector3 _movementThisStep;

    private void Start()
    {
        _previousPosition = this.transform.position;
    }

    private void Update()
    {
        transform.Translate((new Vector3(0, 0, _velocity)) * Time.deltaTime);
    }

    private void FixedUpdate()
    {
        _movementThisStep = this.transform.position - _previousPosition;

        float movementSqrMagnitude = _movementThisStep.sqrMagnitude;
        float movementMagnitude = Mathf.Sqrt(movementSqrMagnitude);

        RaycastHit hitInfo;

        if (Physics.Raycast(_previousPosition, _movementThisStep, out hitInfo, movementMagnitude, _layerMask.value))
        {
            //this.transform.position = hitInfo.point; // Used if you want to spawn effects or something at impact point
            Destroy(this.gameObject);
        }

        _previousPosition = this.transform.position;
    }
}