|
Hey guys, I'm working through the Unity Game Development Essentials textbook and want to add in a trap that steals the player's batteries if they come into contact with it. I have the trap deducting a charge on collision, but I'm stuck on the instantiation of objects. I want to instantiate one of my prefabs and have it fly out of the player as it does so (so they can follow it and see where it landed) I'm using the code from here: http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html But I'm not sure how to define a prefab in the variable. Second question is, does my prefab need a rigidbody for me to 'launch' it out of the player? Thanks.
(comments are locked)
|
|
If you want to define a prefab, write the following line at the top of your script: so the variable name is the prefab I want to create?
Jul 14 '10 at 01:32 AM
Troy
oh right, i'd been forgetting to define it in the inspector, thanks!
Jul 14 '10 at 01:40 AM
Troy
(comments are locked)
|
