Change values.

Hi guys. I am learning about some Unity features and today I was playing around with the Instantiate function.

After writing this quick script…

public class PlayerFeatures : MonoBehaviour {
	
	public GameObject projectileBoomerang;
	Object clone;
	//public Object clone;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	public void InitializeBoomerang(PlatformerPhysics mPlayer)
	{
		clone = Instantiate(projectileBoomerang, mPlayer.transform.position, transform.rotation);		
	}

I am not sure on how to change some of the properties of my boomerang object, for example, the speed. I would like to create more than one boomerang using this method, with each of them having a different moveSpeed.

Thanks.

BommerangScript boomerang = (BoomerangScript)Instantiate(projectileBoomerang, mPlayer.transform.position, transform.rotation);

Then use your “bommerang” reference and set speed and other properties you would like.

boomerang.SetSpeed(someValue);

Of course, you either have to have public function SetSpeed or just public speed variable that you will access directly.