- Home /
Get weird issue when change from Mechanim -> Ragdoll
Hi,
Please see my issue in this video: https://youtu.be/Ml6r4TYZEyA
As you can see in my video:
Enemy: at normal state, it behaves exactly like I control (via scripts and Animator). When it dies, scripts and Animator will be disable/ removed immediately. The enemy will look like a real dead body (thank to Ragdoll)
Issue: I have 2 enemies (let's call them A and B). They are from the same prefab.
(1). If B is created after A is destroyed then everything is fine
(2). But if B is created after A is created AND before A is destroyed, then when B is destroyed, its Animator behaves really weird (as seen in the video)
Of course, this also happened when I have more enemies.
I did look carefully through the code, and I think (2) happened because A and B somehow share the same Animator controller/ avatar, so when B is destroyed, it starts to use the Animator controller/ avatar from A (which is falling really fast; or was destroyed); hence the weird result. This does not happen in (1) case, remember?
(I did not use any static variables/ void,..)
Do you know how to fix this? Thank you so much
Hi, it sounds like you are modifying the prefab itself ins$$anonymous$$d of an instance of this prefab. Well, I guess, it's easy to do this mistake and it could have the effect you describe. $$anonymous$$aybe double checking the code to make sure no prefab is modified. Also, displaying the ID (using GetInstanceID() on $$anonymous$$onobehaviors or GameObjects, and Debug.Log) can help. The inspector can also show this ID using the "debug" mode (right click on the inspector tab and choose "debug" to display additional fields). Doing this, you can make sure the object/animator that is destroyed/modified is the right one and not a prefab by checking the IDs.