so im trying to Instantiate a particle system that i have made into a prefab, so when i pick a object up it destroys it and creates Instantiates the particle system where it was. the problem is its saying a cant use the object’s(the one i need to pick up, which is “HitObject”) position as the second thing in the Instantiate command.
public Transform ParticalSystem;
public float Timeout = 3;
private Transform HitObject;
private RaycastHit hit;
public int GrabDis = 6;
private bool ChangeIcon = false;
void Update ()
{
if (Physics.Raycast(ray, out hit, GrabDis))
{
if (hit.collider.gameObject && hit.collider.gameObject.tag == "Bear")
{
Transform HitObject = hit.collider.gameObject.transform;
ChangeIcon = true;
Debug.Log("hit bear");
if (Input.GetKeyDown(KeyCode.E))
{
Transform partical;
partical = Instantiate(ParticalSystem, HitObject.transform, transform.rotation) as Transform;
Destroy(hit.transform.gameObject);
Destroy(ParticalSystem, Timeout);
}
}
if (hit.collider.gameObject.tag != "Bear")
{
ChangeIcon = false;
Debug.Log("Not hiting bear");
}
}
}