Answer the question
In order to leave comments, you need to log in
How to make prefab mouse tracking?
An example is this - I click to build a tree, for example, when I drive around the stage, where I drive this tree appears (prefab), they say where to put it, something like
public void MouseEnter(){
Instantiate(tree, transform.position, transform.rotation);
}
public void MouseLeave(){
Destroy(tree);
}
Answer the question
In order to leave comments, you need to log in
Your tree is the prefab of the object you are spawning. How do you for-destroy-esh? You have to assign your Instantiate to a GameObject variable and that variable and destroy.
GameObject new_tree;
public void MouseEnter(){
new_tree = Instantiate(tree, transform.position, transform.rotation);
}
public void MouseLeave(){
Destroy(new_tree);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question