Access Violation Crash in Compiled VR game on projectile hit

I have a bug in my Vive VR game where in the executable version of the game, there is an Access Violation crash whenever a projectile hits an enemy. Everything works fine when I run it in the Unity Editor. I submitted a bug report two weeks ago (viewable here), but there’s still been no response whatsoever.

What should I do now? The game is essentially unplayable, I have no idea what’s causing it, no idea if or when I’ll get a response from the Unity support staff, and since it runs fine in the editor, my debugging capabilities are very limited.

Incidentally, my projectile collision code is:

void OnTriggerEnter(Collider other)
    {
        //print(other.tag);
        if (other.tag == "nodeSphere" || other.tag == "exclusionZone")
            return;
        if (other.tag == "enemy")
        {
            Enemy eScript = other.gameObject.GetComponent<Enemy>();
            if (eScript == null)
            {
                Subcollider subScript = other.gameObject.GetComponent<Subcollider>();
                eScript = subScript.parentObject;
            }
            eScript.TakeDamage(damage);

        }

        if (hitObject)
        {
            Instantiate(hitObject, transform.position, transform.rotation);
        }
        Destroy(this.gameObject);
    }

The hit object itself does not cause the crash (tested that), and if I remove the VR functionality and compile, that executable version does not crash when projectiles collide.

So again, what should I do now, since I’ve had no response from Unity support after waiting two weeks? Is this a problem with the SteamVR plugin (in which case I should contact HTC or Valve)? If you actually have a solution to the problem, that would be welcome too! Thanks!

Hi there, a lot of times Access Violations occur when a script’s class name differs from the file’s name. Perhaps your, “Enemy” class name is not “Enemy.cs” or perhaps there is an issue with some of the Vive’s API scripts that conflict with your class.

My suggestion would be to change your Enemy class and file name to something like, “EnemyBehaviour”. It’s a shot in the dark, but I hope it sheds some light.