Accessing instanciation properties C#

hello … how can you specify the public properties of an object when you instanciate it ?
I have tried something like that but it is not working (i am trying to specify
the “Target” public variable) :

public GameObject projectile;
	public float fireRate = 0.5F;
	private float nextFire = 0.0F;

	void Update() {
		if (Input.GetButton("Fire1") && Time.time > nextFire) {
			nextFire = Time.time + fireRate;
			Instantiate(projectile, transform.position, transform.rotation);

// This is where i have issues
			projectile = GetComponents<projectile>();
			projectile.Target = "cible";
		}
	}

thanks for your help guys :slight_smile:

this is all with the understanding that you have a class/type called projectile, it exists as a component on the instantiated projectile gameobject

    public GameObject projectile;
    public float fireRate = 0.5F;
    private float nextFire = 0.0F;
 
    void Update() {
        if (Input.GetButton("Fire1") && Time.time > nextFire) {
            nextFire = Time.time + fireRate;
            GameObject tempObj = Instantiate(projectile, transform.position, transform.rotation) as GameObject;
 
			projectile projectileComp = tempObj.GetComponent<projectile>();
            projectileComp.Target = "cible";
        }
    }

GameObject temp = Instantiate(projectile, transform.position, transform.rotation) as GameObject;
temp.GetComponent().Target = “cible”;