- Home /
Question by
djfunkey · Sep 24, 2012 at 11:05 PM ·
c#instantiateparticle system
Instantiate a partical system
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");
}
}
}
Comment
Best Answer
Answer by Loius · Sep 25, 2012 at 12:22 AM
You need to use HitObject.position; it's already a Transform.
Your answer
Follow this Question
Related Questions
PARTICLE SYSTEM NEITHER EMITTING NOR PLAYING (BY SCRIPT) 3 Answers
Distribute terrain in zones 3 Answers
Prefab Particle clones won't destroy, C# 1 Answer
Multiple Cars not working 1 Answer