How do I move a prefab(clone) in a non attached script

I’m trying to Instantiate a clone in a master control script and get it to move. I can’t figure out how to affect the instantiated clone.

using UnityEngine;
using System.Collections;

public class MasterScript : MonoBehaviour {

public Rigidbody2D cat;
public float speed = 10f;

// Use this for initialization
void Start () {

	cat = (Rigidbody2D)Instantiate (cat, transform.position, transform.rotation);
	cat.transform.Translate(Vector2(0,speed));

}

}

I’m sure this is easy it’s just beyond me for some reason.

Are there any particular reason to why you’re casting it to/as a Rigidbody2D?

A Rigidbody doesn’t have a transform. You should make it a GameObject instead as it has a transform.

public GameObject cat;

cat = Instantiate(cat, transform.position, transform.rotation);
cat.transform.Translate(Vector2(0, speed));

Try doing it this way. Please let me know if this solved your problem. Please feel free to correct me if I’m wrong on this.

Ok. I made these changes to lines 12 and 13

cat = Instantiate(cat, transform.position, transform.rotation) as GameObject;
cat.transform.Translate(new Vector2(0, speed));

The object shows up as cat(clone) but does nothing. I get this error while the game is running

NullReferenceException: Object reference not set to an instance of an object
MasterScript.Start () (at Assets/Scripts/MasterScript.cs:13)

I don’t understand why this is so difficult. It seems like a basic idea. Create an object in the scene and make it move, from point a to point b or whatever. I’d think this would be a common thing to do in most games.

Hi, i have the same problem, my main object moves but its clones not.
I do it in this way

1)Generating my cubes on the scene

public class random_generating : MonoBehaviour {

	public GameObject Cube;

	// Use this for initialization
	void Start () {
		for(int i=0; i<5; i++)
		Instantiate (Cube,new Vector3(1.5f,3.34f,0.0f),Quaternion.identity);	
	}
	
}

2)Cube moving

public class cube_moving : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		transform.Translate (0, 0, Time.deltaTime*(-5));
		//transform.Translate(0, Time.deltaTime, 0, Local.World);
	}
}

I know that my piece of advice does not allow your problem, but as another idea can little inspire you for smth else(sorry for my english, i am ukranian))