Reply To: I would like to have a button, that when I press it, it instantiates a prefab at a certain location. For me that sounded s…

Forum Archive I would like to have a button, that when I press it, it instantiates a prefab at a certain location. For me that sounded s… Reply To: I would like to have a button, that when I press it, it instantiates a prefab at a certain location. For me that sounded s…

#23058
Jonathan Gonzalez
Participant

    That almost always happens when I ask a question so I know the feeling. A couple things I wanted to mention. If you’re not using the “int scene” then leave it out. It was added because that function could be used with any button then we could just change the number for a specific level. So one function with three buttons that load 3 different levels.

    Also you could just make your Instantiation function, SpawnWeapon(), public and just use that directly with your button. That function will only be called when the button is pressed. Just make sure it’s not included within the Update function, otherwise it’ll automatically instantiate objects.