|
Is it possible to have a prefab in my scene but inactive (unchecked in the inspector) then on a trigger event activate it? what I am trying to do is have a forcefield activate, i've tried instantiating on trigger (and parenting to an empty gameobject) but this fails as for some reason keeps appearing in different locations.
(comments are locked)
|
|
Yes you can do that. When you want to activate it - call
by reference do you mean do a var forcefield : GameObject; ?
Jun 16 '12 at 10:59 PM
carter.carl30
Make sure the object you referenced in the inspector as "forcefield_powerup" is the instance of your prefab that you manually dragged into the scene, not the actual prefab in the "Project" view.
Jun 16 '12 at 11:45 PM
Wolfram
Select the prefab in the hierarchy view and drag it onto the forcefield_powerup. That will work if the prefab is instantiated in the scene.
Jun 17 '12 at 09:13 PM
whydoidoit
Which object do you have selected, meaning, which object is shown in the inspector? The actual script? Or the object your script is attached to?
Jun 17 '12 at 10:26 PM
Wolfram
You cannot assign scene references to a prefab. We thought the object you were talking about was also part of your scene, not part of a prefab itself. If it's not possible for you to use a scene instance for that prefab, too, you'll have to use a different method to assign the reference. For example, create a GameObject var in the script that actually instances "save_line_powerup", where you can drag the forcefield_powerup object (unless that instancing script is also merely a prefab...), and then assign it via script, directly after the line that instances "save_line_powerup".
Jun 17 '12 at 10:57 PM
Wolfram
(comments are locked)
|
