- Home /
Adding a transform component to an object which is not in the hierarchy
Hi, I want to achieve the following:
I got a gun object. That object spawns on the player when the game starts. ( I do it this way to have gun pickup from the ground covered in the future)
But, on the gun object, I want to add my Firepoint transform component. This doesnt want to be working. When I click the gun object, and drop the Firepoint on my transform field in the gun script component, I can't.
When I do this with the gun in the hierarchy, I can. But however, if I drop the gun with the transform component in the Assets, the transform component dissapears? how to fix this?
Answer by xxmariofer · Mar 19, 2019 at 11:17 PM
you cant fix that, you cant assign a transform to a prefab since that prefab isnt in that scene, a workarround is to leave an instance of the object you want to spawn in the scene, and assign that instance rather than the prefab
Yeah that makes sense. I figured out that I can do it via code aswell :)
Your answer
