- Home /
Question by
John00 · Feb 24, 2014 at 04:28 AM ·
gameobjectinstantiaterandomoffscreen
Instantiate Prefab from outside Camera view
I'm wondering how I could create Instances of a gameObject (say a sphere for instance) at a random position thats just outside of view from an orthographic camera. I managed to get something similar by using the Camera.main.ViewportToWorldPoint
and passing a Vector3
such as (0,0,Camera.main.nearClipPlane)
which would get the top left corner (I believe) but this solution only accounts for the corners and not all the edges.
I've spend the last couple of hours trying and searching to no avail, I'm sure this is pretty simple, Just can't wrap my head around it.
Comment
Outside on all sides of the view or just a particular side? Is the camera centered on the origin. That is, is the camera x and y both 0?