Hi everyone - I have a particle system that is instantiated when another object collides with it - however I want it to move with the parent it is a child to. This is the current code I have, but it doesn't seem to be following the parent, just stays in the place it was instantiated. Thank you!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParticleInstantiate : MonoBehaviour
{
public GameObject transmissionParticles;
public GameObject parentObject;
void OnCollisionEnter (Collision coll)
{
if (coll.collider.CompareTag ("Transmission"))
{
Transmit ();
Debug.Log("collided");
}
}
void Transmit ()
{
GameObject transmission = Instantiate(transmissionParticles, transform.position, transform.rotation);
transmission.GetComponent().Play();
transmissionParticles.transform.parent = parentObject.transform;
}
}
↧