- Home /
Spawn a prefab off screen?
Hey I'm setting up enemy spawning for my game and ran into a problem. The enemies spawn at predetermined spawn points stored in the Spawn Manager object. That works just fine but what I want is for the enemies to only spawn at a spawnpoint location that is not currently on screen and am drawing a blank on how to do that.
So I guess my question is...how do I check if a world position is currently visible on screen without it having a renderer of any sort?
$$anonymous$$ay I ask why you are wanting them to spawn off screen? Is it to spawn them, then later bring them into view later?
I want to avoid enemies just popping into view. $$anonymous$$y other option is a "spawning animation" or something but that seems a little hacky I$$anonymous$$O for most enemies.
Answer by jimmycrazyskills · Dec 17, 2018 at 09:10 PM
Hi mate not sure if this solves your problem, but could you use the Renderer.isVisible
property.
1. Add an empty renderer to you spawn points
2. Find the object you want to check is on the screen
3. Get the Renderer component attached to the object
4. Read the Renderer's isVisible property
Just a heads up, the object is considered "On the screen" even if it's only its shadow is showing!
Hope this helps =D
Your answer
Follow this Question
Related Questions
Problem instantiating a prefab, and storing a reference to it. 1 Answer
How to instantiate an object on multiple positions? 0 Answers
Intantiated objects being created but being invisible...[PICTURES] 1 Answer
why is it slow to instantiate 0 Answers
instantiating prefab does not rotate child objects correctly? 1 Answer