Hello folks!
I’ve searched lots of similar cases, but unfortunately none of the solutions would seem to help me.
Well, all I want to do is instantiate a smoke effect prefab when my object is colliding with a trigger wall, so I wrote this:
using UnityEngine;
using System.Collections;
public class pickStarController : MonoBehaviour {
public SpriteRenderer smokeEffect; //The Prefab
void OnTriggerEnter(Collider other){
if (other.gameObject.tag == "WallBounds") {
SpriteRenderer smokeColor = Instantiate(smokeEffect, this.transform.position, Quaternion.Euler (new Vector3(0, 0, 90))) as SpriteRenderer;
smokeColor.color = Color.red;
}
}
}
As you can see, I’m trying to instantiate as a SpriteRenderer type so I can change the color of the object after instantiated, but I’m getting this error after the object is created ingame:
So you guys are my last hope, because I don’t want to have to create and attach a new script to the prefab, since I can quickly edit it right after the instantiate process…
Thank you very much for your attention and help.