Question by 
               jaredlan · Jan 20, 2021 at 11:47 PM · 
                instantiateprefabparticlesysteminstantiate prefabcs  
              
 
              Get a Insantiate particle system follow a GameObject
I'm working on a space invader Magic Leap project and I want all the instantiated prefabs (explosions, smoke, etc) follow the planet if I want to move it. This is the missileScript, it seems like in line 25 there is a transform.position that follow the location of the planet. Unfortanenly it's not doing it. How can I do that?
using UnityEngine;
public class MissileScript : MonoBehaviour { public GameObject planet; public float speed; public GameObject explosion; public GameObject damage; public int crashed; public float minDist;
 // Start is called before the first frame update
 void Start()
 {
     crashed = 0;
 }
 // Update is called once per frame
 void Update()
 {
     transform.LookAt(planet.transform.position);
     transform.position = Vector3.MoveTowards(transform.position, planet.transform.position, speed);
     float dist = Vector3.Distance(planet.transform.position, transform.position);
     if (dist < minDist)
     {
         Instantiate(explosion, transform.position, Quaternion.identity);
         Instantiate(damage, transform.position, Quaternion.identity);
         Destroy(this.gameObject);
     }
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                