Skip to content

Instantly share code, notes, and snippets.

@mr-brooks-dev
Created July 9, 2023 17:03
Show Gist options
  • Select an option

  • Save mr-brooks-dev/b5b32020882a3e377f15fd6e7695622f to your computer and use it in GitHub Desktop.

Select an option

Save mr-brooks-dev/b5b32020882a3e377f15fd6e7695622f to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeltObject : MonoBehaviour
{
public GameObject particlePrefab;
public string targetTag = "Lava";
public float objectDestroyDelay = 1f;
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag(targetTag))
{
Instantiate(particlePrefab, transform.position, transform.rotation);
Destroy(gameObject, objectDestroyDelay);
}
}
}
@mr-brooks-dev
Copy link
Author

Super simple Unity script for instantiating a flame particle prefab and then destroy the object the script is attached to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment