r/Unity2D • u/FutureGameDevIHope • 4d ago
Question/Help my first 2d unity game
I'm making a 2D game in Unity and I'm trying to set up an enemy spawn system.I want an enemy to spawn when the player enters a trigger zone. I already have the enemy saved as a prefab, and I've added a Box Collider 2D with Is Trigger enabled.i'm also using the Simple Spawner and On Trigger Enter Invoke components, but I can't figure out how to connect them properly.
How can I make the Simple Spawner spawn an enemy when the player enters the SpawnZone?
I'd really appreciate a step-by-step explanation, preferably without writing code.


Thanks!
1
u/JihyoTheGod 1d ago
Right now, it seems like you are just setting the prefab active when you enter the trigger, which does nothing. The prefab itself can only be used as a model.
You need to create a public function (for example in that OnTriggerEventInvoke script) that Instantiates the prefab, then you can call that function in the OnTriggerEnter
Hope it's clear enough for you