2

I've set up this enemy to turn into a ragdoll upon death, fly into the air a bit, and behave like a ragdoll. It is all working fine as far as i can tell.

Except i am encountering an issue where the enemy keeps popping in and out of existence, depending on the cameras rotation/position.

Here is what it looks like before the issue.

enter image description here

Then, from this position, if i rotate the camera slightly, it results in this:

enter image description here

The game is paused while this is happening so it is not related to movement in any way. I can also rotate the camera back and forth, and the model will continue to pop in and out of existence. No gameobject is being destroyed.

It it also nothing to do with the model clipping into / under the floor, as you can see in the pictures, i raised it up off the floor to test it, and it still happens while suspended in mid-air.

This issue only happens while the enemy is a ragdoll. If i turn off ragdoll deaths nothing like this ever happens.

Do you have any idea what could be causing something like this?

niar88
  • 41
  • 4

2 Answers2

0

I am guessing that your enemy is using the skinned mesh render component. When using ragdolls and skinned mesh renders together the bones or vertices of the rig might get pushed out of bounds. Unity only renders your mesh if the bounds of it are in the camera view. The unity docs recommend either increasing the bounds or turning on "Update When Offscreen" on all of your skinned mesh renderers.

More info here

Zaleyact
  • 51
  • 5
0

This is very easy to miss as it is only visible if you PAUSE the game to inspect the model/Skinned Mesh Renderer in Scene View so I'm putting it here for anyone struggling if that's the case.

enter image description here

Skinned Mesh Renderer has a Root Bone property which is many times set to the Root bone(or even None) and not the Hips bone of the character. In some imported models (and from the looks of it I guess this is a Synty model which has EXACTLY the issue I am going to describe) adding a ragdoll can result in the Renderer not following the model as a whole the way we want and this can lead in strange behaviors, one of whom can be disappearing completely from the game screen.

Assign the Hips Bone as the Mesh Renderer Root Bone, so it can follow the position and rotation of the model.

Note : If the hips bone has any rotation because of how it was created as a model, the result can be weird. To fix this create an empty gameObject inside the Root bone, then place it inside the Hips Bone and finally assign it as the Root Bone of the Renderer.

This way the Skinned Mesh Renderer will follow the character and you won't see it randomly disappear!

enter image description here

Aris13
  • 41
  • 6