Quantcast
Channel: Questions in topic: "side-scrolling"
Viewing all articles
Browse latest Browse all 99

Determine if GameObject with no renderer is within Orthographic camera bounds

$
0
0
I have a 2D sidescrolling game that is pseudo randomly generated. It reads in "rooms" which are 10x10 tile segments. I have a GameObject Room which basically manages all the tiles, which are 2D sprites. The Room class has no renderer itself, but it does have a Bounds member that wraps the bounds of all the tiles it contains. Rooms are positioned directly next to each other to appear as once seamless level. I have the camera scrolling to the right and want to test when a Room leaves the Ortho camera's view so I can dispose of the room and recycle it at the other end of the level. Trying common methods for this such as `GeometryUtility.TestPlanesAABB(planes, rooms[0].RoomBounds)` does not yield the right behaviour. It returns true long after the room has apparently left the camera's view. It eventually returns false, but not until it has crossed the mid-point of the NEXT room. I believe it's likely I'm not understanding something about that test and how it works, or perhaps it isn't intended for an ortho camera. FWIW, the "Rooms" area always smaller than the width of the camera. With the camera still, and the first room at the far left of the viewport, ~1.5 rooms are within the camera's view. Does anyone know the proper way to test something like this. Most examples I've seen require the object you're testing to have a renderer of some sort. Thanks in advanced!

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>