- Home /
Ragdoll : slight pause before it starts?
Hi,
i am using a ragdoll on my ZTE Android 2.2, it works fine, except that just before the ragdoll starts to fall down : there is a slight pause for about 1 second or less. But then, the ragdoll works fine.
I thought the problem came from the loading, so i loaded an instance of my prefab first, in the function "Start", i waited a bit and triggered the ragdoll. But same result. Do you think it is because of my device? Or because of the ragdoll itself on mobile?
I have one character : 1800 faces, 25 bones
and then i instantiate a light version for the ragdoll : 1200 faces, still 25 bones
Would you know any tip to make this work without this slight pause?
Here is the code i am using :
private var instance : GameObject;
private var instanceT : Transform;
function Start () {
instance = Instantiate(Resources.Load("runpref"));
instanceT = instance.GetComponent(Transform);
}
function Detonate () {
Destroy(gameObject);
if (instance) {
CopyTransformsRecurse(transform, instanceT);
}
}
static function CopyTransformsRecurse (src : Transform, dst : Transform) {
dst.transform.position = src.position;
dst.transform.rotation = src.rotation;
for (var child : Transform in dst) {
// Match the transform with the same name
var curSrc = src.Find(child.name);
if (curSrc)
CopyTransformsRecurse(curSrc, child);
}
}
function Update () {
if ((Input.touchCount > 0) || Input.GetKey("z")){
Detonate();
}
}
Thanks a lot
Answer by justin35f · Jan 19, 2013 at 04:49 AM
Try to instantiate it in the Awake() function. I believe that this triggers slightly before Start() function.
Thanks, no unfortunately it does not work, i still have the same pause...
That's unfortunate. For future reference though:
The Start function is called after all Awake functions on all script instances have been called.
This comes from the Start page in the Unity script reference docs.
Your answer