2D Unity Instantiate Ragdoll, same Transform as Sprites ( Head, Torso, LArm,RArm,LLeg,RLeg)
Is there a way to store an enemys or players transform of all body parts and translate them to an newly instantiated ragdoll?
Thanks in advance for any help!
Answer by BOB_KSE · Dec 24, 2017 at 11:18 AM
Store all the body parts(child Objects) in a parent GameObject. Make a script similar to the one given in the following link and instantiate the parent object.
I guess if you try dragging the position of the pivot of all the body parts (limbs & head) towards the torso region. It may give the ragdoll effect you are looking for. i have never tried it though.
Answer by DuB86 · Dec 24, 2017 at 10:43 PM
I already have an extra Gameobject as a functioning ragdoll, the problem is if it is instantiated e.g. the limps are not on the same postion as the limps when my character died
@DuB86 Sorry, I cant think of an efficient way of solving this problem. you can create a script in your ragdoll GameObject which has a function that receives 6 transforms as parameters.
eg:
public void RecieveTransforms (Transform head,Transform torso,Transform Leftarm,Transform rightarm,Transform LLeg,Transform RLeg){
this.GetChild("Head").Transform = head;
this.GetChild("Torso").Transform = torso;
this.GetChild("LArm").Transform = Leftarm;
this.GetChild("RArm").Transform = Rightarm;
this.GetChild("LLeg").Transform = LLeg;
this.GetChild("RLeg").Transform = RLeg;
}
Call this function from your player script before instantiating the ragDoll GameObject. //hope this helps in some way...
Your answer
Follow this Question
Related Questions
snapping the Players psosition to another GameObject for a "Ledge grab" 0 Answers
Problem when instanciating objects on keypress 0 Answers
Wrong position (always 0,0,0) when Instantiate prefab. 1 Answer
Why is my gameObject in a different position on galaxy s4? 1 Answer
How can I change position of instantiate objects (clones)? 1 Answer