Edit:
TL;DR – It’s definitely a Unity bug.
So I have a “skill” or “ability” in my game that creates a shield bubble around my player. The player inherits from a destructible object which lets the player take damage. The shield bubble object also inherits from destructible to keep things simple. But the bubble has the invincible boolean toggled (obviously something I created) and it prevents the shield from taking damage. Once the timer runs out the shield object is destroyed, except we noticed that the player can no longer take damage. It took us a while, but we found that the player’s collider remains wherever the shield bubble ended. So like, I could be taking damage at (0, 0), but then if I move to (5, 8) I’ll stop taking damage, and then if I move back to (0, 0) I’ll take damage again. As if my collider component somehow became detached from the player object. It’s a component so I don’t know how that’s possible, but it’s happening.
I know this is kind of unclear, but it’s hard to describe what’s going one without writing a novel. Feel free to ask for clarification. Two of us have spent a decent amount of time now trying to figure this out with no luck.
Thanks in advance for any help.
It might help if you could post screenshots of your editor, specifically the Hierarchy window as well as the Inspector window for each of your gameobjects.
I have to be honest, I think it’s a Unity bug. I’ve spent HOURS going over every small detail in the inspector, hierarchy, scene, scripts… I’ve used breakpoints and debug messages every step of the way. It boils down to this. I have a convex mesh collider that works perfectly until I create a Sphere primitive with a sphere collider and then destroy it. I toggled Convex off during gameplay and started taking collisions again. I toggled it back on and collisions resumed. So literally nothing changed and it started working. So for now I’m going to just toggle it in my code as a HACK fix and we’ll get back it to later I suppose.
Here’s the code that “fixes” my problem. Pretty weak.
public void TearDown() {
Executing = false;
//HACK to prevent collision from breaking
GetComponent<MeshCollider>().convex = false;
Destroy(Shield);
StartCoroutine(EnableMeshCollider());
}
//HACK to prevent collision from breaking
IEnumerator EnableMeshCollider() {
yield return null;
GetComponent<MeshCollider>().convex = true;
}
Might be a good idea to file a bug report.
William