Hi, i have a coin which has an animation and an effect
so after the coin is picked up, the the game object coin will be destroyed and so will the clone after 3 seconds
but i get this error
“Can’t destroy Transform component of ‘Coin_Effect(Clone)’. If you want to destroy the game object, please call ‘Destroy’ on the game object instead. Destroying the transform component is not allowed.”
How to remove this error?
Here is the code
using UnityEngine;
using System.Collections;
public class CoinPickup : MonoBehaviour
{
public Transform coinEffect;
// Update is called once per frame
void OnTriggerEnter (Collider info)
{
if (info.tag == “Player”)
{
Object effect =Instantiate(coinEffect,transform.position,transform.rotation);
Destroy(effect,3);
Destroy(gameObject);
}
}
}