unity3d - Can I know in Unity 5 who Instantiated the object? -
is possible information instantiated object 1 instantiated it?
for example let's have objecta:
instantiate(objectb, gameobject.transform.position, quaternion.identity);
is there way in objectb:
awake() { var vector = parent.transform.position };
where "parent" initiator.
you can following accomplish that:
// in objecta class's function gameobject objb = instantiate(objectb, gameobject.transform.position, quaternion.identity); objb.parentpos = transform.position; // , if want know instantiated it, use line: objb.parentgameobj = gameobject; // in objectb class public vector3 parentpos; public gameobject parentgameobj;
Comments
Post a Comment