I wrote two little scripts to manage platform spawning. 1st - is attached to the Spawner gameObject. It's uset to spawn new platform. 2nd - is something like Platform Manager which not extend MonoBehaviour.

I want to set Spawner to create new platforms after old one goes off screen. But I dont know how to get current position of instantiated platform for example to check if platform is actualy off the screen.

Below my scripts:

1st. Spawner

void Update() {


public void NewPlatform() {

    if (active) {
        newTransform = transform;
        PlatformManager.Instantiate(prefabs[Random.Range(0, prefabs.Length)], newTransform.position);              


2nd. PlatformManager

using UnityEngine;
using System.Collections;

public class PlatformManager {

public static GameObject Instantiate(GameObject prefab, Vector3 pos) {

    GameObject instance = null;

    instance = GameObject.Instantiate(prefab);
    instance.transform.position = pos;

    return instance;


Briefly - haw can I get current position of instantiated object (or other parameters) from Spawner script?

Thank you in advance.

  • \$\begingroup\$ You already have it. newTransform.position \$\endgroup\$ – Evorlor Jul 23 '15 at 13:23
  • \$\begingroup\$ something isn't adding up. You may want to go back to the whiteboard \$\endgroup\$ – Evorlor Jul 23 '15 at 13:33
  • \$\begingroup\$ But this script is attached to Spawner which is not movinng. So if check position for example in Update method: Debug.Log("Current position: " + newTransform.position); it always return 0,0,0. \$\endgroup\$ – MaD Jul 23 '15 at 15:07
  • \$\begingroup\$ I understood that. The reason you are having trouble is because you are on the wrong path. You need to backtrack, not move forward. I know it is hard to do, but i sincerely suggest deleting these 2 scripts, calling it a day, and looking at it fresh tomorrow. That is what I would do. \$\endgroup\$ – Evorlor Jul 23 '15 at 15:11
  • \$\begingroup\$ instance.transform.position = pos - transform.position should do the trick. Or just use instance.transform.position = transform.TransformPoint(pos) \$\endgroup\$ – Leggy7 Jul 23 '15 at 16:11

Try attaching a script to your platform instances. Then in that scripts Start() method use Debug.Log to log the parent platforms Transform

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.