- Home /
Grabbing a Prefab Reference from Object Instance
As the question states, I'm wondering if anyone knows a trick for grabbing a reference to the prefab that would instantiate an object from its instance. I'm trying to perform a distance check between two objects, A and B. If B is too far from A, I want to store information about B in a third object, C, as well as the prefab that was used to instantiate B. Later, C will detect the position of A and reinstantiate B if B was close enough to A, but it needs a reference to the prefab to do that. If I am approaching this completely wrong, I'm also open to other suggestions.
Being unfamiliar with the forums and this being my first question asked, my question appears to be stuck in moderation so I have developed my own solution. I have decided on passing the string path to the prefab in the Resources folder to object C whenever object B is destroyed upon A beco$$anonymous$$g too far away. This way, whenever A becomes close enough to C, C will be able to respawn object B using the string path to the Resources folder location of the prefab for object B. I am still certainly open to other suggestions if someone has a more efficient solution.
Your answer
Follow this Question
Related Questions
Change materials of connecting objects 0 Answers
Swapping Objects 3 Answers
Duplicated objects go crazy at runtime 0 Answers
Camera Following Multiple Objects 0 Answers