Hello,
I created a Prefab Smoke PS that has a default color of white. I want to use it on three different GameObjects, each one of them with a different color. When the GameObject gets destroyed, I want the PS to show up where the GameObject was - in the color of the now vanished object. The tutorial series I follow uses an older version of Unity, and the way it was done there does not seem to work anymore. The positioning of the PS works perfectly fine, but I can’t seem to find a way to change the color of the PS. Can you guys help me out?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Brick : MonoBehaviour {
public GameObject Smoke;
private int timesHit = 0;
private int maxHits;
private bool isBreakable;
public static int breakableCount = 0;
[...]
void OnCollisionEnter2D (Collision2D brickHit){
if (isBreakable) {
timesHit++;
if (timesHit >= maxHits) {
GameObject smokePuff = Instantiate (Smoke, this.transform.position, Quaternion.identity) as GameObject;
smokePuff.GetComponent<ParticleSystem> ().main.startColor = this.GetComponent<SpriteRenderer> ().color;
DestroyObject (gameObject);
breakableCount--;
}
It returns this Error messsage:
Thank you so much for your time.