Problem appeared in Unity 2018.1.5f: activate/deactivate colliders at runtime results in being ignored
Hi everyone,
I discovered an issue with Unity 2018.1.5f that was there before (at least, it wasn't here in Unity 2018.1.1f).
Context:
I have a system to render levels at runtime. Basically, I instantiate/destroy and active/deactivate parts of a level at runtime. My scene has terrain and obstacles using mesh colliders, box colliders, etc. Before Unity 2018.1.5f, that worked perfectly fine.
Issue:
Now, with Unity 2018.1.5f, when I instantiate and activate parts of the level, the character controller 3d sometimes recognizes the colliders sometimes ignores them and ends up falling through the ground.
Tests and observations:
I made a lot of tests and ended up completely deactivating the rendering system. Which means the whole level is always rendered and activated in the scene before the game launches. Issues are gone. The character controller never falls through the ground anymore.
In both cases, it's the same character controller, the same level content. The only difference is the level is already there at launch or the level shows up after the game is launched.
Code:
The code to instantiate and activate isn't weird at all, here is what the code looks like:
public void RenderInstantiate() {
if (!Instantiated) {
GameObject roomPrefab = Instantiate (generationConfig.prefab);
roomPrefab.transform.SetParent(PrefabHolderGameObject.transform, false);
Instantiated = true;
}
}
This code is called by a co-routine. And I know the code runs because the level does appear. I honestly don't see how this could be simpler... Has anyone else encountered this issue?
Thanks in advance!
Hey, I made a little test project that shows the issue.
Here is the link: https://1drv.ms/u/s!AuZP0yp$$anonymous$$LfiVhDQm24TkVl8ekqAL
Everything is in the sample scene.
Test with runtime generation: Stop the game (if running), click on the Game$$anonymous$$anager in the scene and check the "Generate At Runtime" option. Press play and walk around with the character: falls through the ground...
Test without runtime generation: Stop the game (if running), click on the Game$$anonymous$$anager in the scene and uncheck the "Generate At Runtime" option. Press play and walk around with the character: everything is okay!
I tested this project with Unity 2018.1.5f and Unity 2018.1.1f. The issue only shows up in Unity 2018.1.5f, so something changed since 2018.1.1f.
Anyone has an idea for a fix?
Well, I submitted a bug report to Unity and they recognized that is is an issue on their side. Here is the link: https://fogbugz.unity3d.com/default.asp?1050751_it6v6njpvqdrr5mj I hope they fix this soon!
Answer by vchevalier · Jun 20, 2018 at 12:22 PM
Unity reported back that they couldn't reproduce the bug in their internal version, so they somehow resolved the issue. Paulius from Unity QA team informed me that the devs are looking for the actual fix and backport it. So I guess the problem will be fixed soon in a new Unity release. Case closed for me. :)
Your answer
Follow this Question
Related Questions
Projectile colliding with player at origin,Excluding a specific game object 0 Answers
How to get the position of the border of a collision (MeshCollider) 1 Answer
Enemies spawning on top of each other,Enemies spawn on top of each other 0 Answers
How do you a attach script + event function to another script during runtime in unity? 0 Answers
cube stacking while parented 0 Answers