Spawning a ragdoll with "on death" event for health script

sneekyo

Member
When you kill a monster in my game, I use the "on death" event for the health + attribute script to spawn a ragdoll of the monster, however the ragdoll always seems to spawn in at some weird angle, and not the angle of the prefab. What can I do about this? Thank you!

-S
 
How do you spawn the ragdoll? The health component spawns objects with the same position and rotation as the character/object it is attached to.
Code:
var spawnedObject = ObjectPoolBase.Instantiate(m_SpawnedObjectsOnDeath[i], m_Transform.position, m_Transform.rotation);
 
Would there be a way to have it spawn in position but not rotation? Then it would perhaps just pick the rotation of the prefab?
 
No, as you see in the code, it will always take the rotation of the character. Instead of spawning your ragdoll directly, you could write a spawner that spawns the ragdoll in whatever position/rotation you need it. Then you spawn an object with the spawner attached.
 
So this spawner script would attach to the ragdoll prefab, then when the Health death event script spawns in the ragdoll prefab the spawner script attached to it would put it in proper place?
 
Top