Closed a-ivanov closed 3 years ago
Thanks for suggesting a new feature.
There are a few catches when dealing with ped's death:
Even better networking solution would be to create separate network object when ped dies. This network object will contain ped's model and ragdoll. This way, ped's dead body can persist on server for as long as we want, and all newly connected clients will spawn this dead body when they connect to server.
what do you thing about generating such structure runtime for each Ped? Maybe the same time when PedModel Frame children are loaded?
That would be one solution. But I don't know how much time it takes to generate ragdoll. If it takes too much, then something else should be tried, like using a prefab with already generated ragdoll.
As for your second use-case (extended collision check), I am not sure if this is the best way to implement it. But I haven't researched about other options.
Thank you for a detailed answer!
Ragdoll generation: the one auto generated by Unity is fine. As long as we can do it via Editor I think there is a way to call it programmatically. Got to find out about this Ragdoll Builder API more. The prefab look like a viable option too.
The simulation and networking: I'm inclined to agree with the separate GameObject solution at the moment (ragdoll physics components + PedModel component). I think I'm going to try this out a little.
As for the extended collision check: I agree that it is a whole separate topic on its own, got to focus on Ped death state on first iteration.
Actually, I did a little research about detecting which part of body was hit with a bullet. And it turns out that the only way to accomplish this is to add colliders to bones.
Ragdoll as a prefab may not work well, because every ped has a different model. So, it would be ideal if we could generate it at runtime, with small performance cost.
got to focus on Ped death state on first iteration
There won't be a death state. Ped's game object should be destroyed immediately (when health reaches 0), and then a new network game object should be created which represents dead body. So, there is no additional state.
There won't be a death state
No, no, a wrong word was chosen. I meant the Ped death feature, not the new Ped state. I got the idea about new network object.
And it turns out that the only way to accomplish this is to add colliders to bones.
I read about it too. The way I see it we can completely substitute single Character Controller component (the one defined in Ped prefab) with these auto generated Colliders + Rigidbody components. Or maybe switch between the two depending on conditions if needed.
The ideal character will have one rigid body for movement and interaction with the world, and a ragdoll which is activated in specific cases (for now, when ped dies) and is used for bullet raycasting. But this is completely different topic. We can't remove CharacterController right now, because all movement and ped logic depends on it.
Alright, I'll try to implement a death feature then first.
Closing as it is done in PR #103.
I have applied Unity Ragdoll Wizard to PedModel child objects with Frame components (a.k.a. bones). Here is a result when the Animation component is turned on and then off:
Bones defined in PedModel were mapped like this:
For each bone-containing object Unity created:
We may use this Ped physics structure in two ways:
The question is: what do you thing about generating such structure runtime for each Ped? Maybe the same time when PedModel Frame children are loaded?
I wanted to ask a community before trying to implement such feature.