In my program, I’m supposed to create an instantiated particle-system, and then translate it to the location of a certain clone. However, I have found no good way of doing this; the idea I had was called “obsolete” by Visual Studio, and I don’t know how (Or if) I can use GetComponent <>() in this situation either.
Here’s the code I have now:
(To instantiate the Clone)
Rigidbody rb;
rb = Instantiate(fallingObject,position,rotation);
rb.name = "Clone";
(To move the particle-system to it’s location)
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name =="FallingObjects")
{
Destroy(this.gameObject);
}
if(collision.gameObject.name == "Ground"||collision.gameObject.name == "Player")
{
Rigidbody rb = gameObject.rigidbody;
Destroy(Instantiate(particles, rb.position, rb.rotation));
Destroy(this.gameObject);
}
}
Again, my main issue is with the “Rigidbody rb = gameObject.rigidbody;” line of code; it says that it’s obsolete and that there’s a better answer than just that, however I need to get an instantiated clone, so GetComponent<>(); wouldn’t be able to pick up the precise clone that I need to do that to.
Thanks a million for your help