- Home /
Having trouble with cloning with prefabs
Alright, so I'm trying to make it so that when you press a button it will spawn a placeable object that you can move around but there are a few problems. 1. When pressing the button it will spawn a tree that you can move around with just moving your mouse but if it interacts with other trees it will unselect and not be usable 2. If you press left click, the normal key to spawn a tree, you will stop moving it and it will go on a random number on the x-axis and disappear So that is the problem, and the weird thing is, I never told the clone to do any of this, its like it has a mind of its own. So any help would be great.
My code
The link to your code gives me a 404 error. However, it sounds like you have some physics enabled and Unity physics will work automatically without you coding it - do you have any rigidbodies or colliders attached to your trees?.
Answer by EvStg · Jun 04, 2021 at 09:45 AM
Hi,
I don't know if I have well understand your problem but it seems to me that you have made a prefabs of the tree with his behavior (1&2 with pressing buttons).
If you create a prefabs it's like you create a real clone with the same behavior so it's clearly totally normal that the "clone" which come to the first tree prefabs acts like the first tree.
Maybe you can just unselect the script in charge of the 1&2 behavior in your clone if you don't want this behavior ? Or create a prefabs with just the appearance ?
Hope it helps you !
Your answer
Follow this Question
Related Questions
How to generate different diagonal platforms? 1 Answer
Instantiated Prefab doesn't appear? 3 Answers
Why is my Prefab Instantiating when the Scene is Loaded? 2 Answers
Is there a way to Instantiate a button prefab as a child of a Canvas? 2 Answers
How to instantiate a gameobject by aligning it to another one 2 Answers