theres 2 errors which says : the best overloaded method,argument #3 cant convert…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bulletDestruction : MonoBehaviour {
public GameObject particleEffect;
public Transform particleSpawn;
void OnCollisionEnter()
{
Destroy ();
}
void Destroy()
{
Instantiate (particleEffect,particleSpawn,particleSpawn.rotation);
Destroy (gameObject);
}
}
You should not create a Function with the name of an existing method. Destroy already exists and you may well confuse the compiler by calling Destroy(object) from within a function called Destroy(). You are redefining the function so to speak.
You also need to reference the transform position for your Vector3 and not the whole Transform.
If you look at Instantiate in the scripting API youll see at the top of the page a list of 5 versions of Instantiate. These are ‘Overloads’ and you must match one of those patterns. It is this to which the error specifically refers. You can see that as Argument #2 in your Instantiate is actually referring to Transform. As a result it looks at the list of Overloads and picks the one this currently fits. This would either be #3 Nothing or #3 bool instantiateInWorldSpace as that’s what is in the Overloads that have the pattern 'Instantiate(Object,Transform' . When it sees the rotation it gets confused and can no longer find a matching Overload, hence why it says #3.
The problem i can see is that you are using particlespawn to set the place where to spawn the object. But it’s asking for a vector and not a transform.
Meaning that the instantiate part should look like this:
Instantiate (particleEffect,particleSpawn.position,particleSpawn.rotation);