- Home /
Clamp camera within bounds of a Complex Mesh?
I have been able to keep the position of a camera within the bounds of two given points: center and size. And that works great! I also draw it with Gizmos.DrawWireCube. I'm able to clamp the position of the camera so that it won't go outside of this "cube" that is made out of these two points.
My question is, how can I start doing this with more complex shapes, and take out the whole "center and size"? If I make a map for the game I am building, and I have a mesh of cubes that I combine to create a weird looking polygon, how can I keep the camera inside of this? I'm sure I wouldn't use Clamp, since that would be very complicated. I could detect which Cube the camera is in, and only Clamp it within that cube unless they go into another one that is adjacent. But that's complicated! Should I do this with collisions? Triggers? That would seem most easy and efficient. Here's an image to demonstrate:
Edit The Clamp I showed in the image is wrong: I forgot to offset by the center. But the question still stands.
Answer by Firedan1176 · Jan 04, 2016 at 02:09 AM
Using a mesh collider and Physics.CheckSphere()
worked great.
Hi I am struggling with this issue too, can you elaborate more how you solved it?, by the way you are talking about 2d right?
I know this is old, but like ido100, Id like some more detail on your solve. Thanks!
ps ido: his application is 3d, but should be similar.
Answer by hexagonius · Jan 03, 2016 at 10:51 PM
quick Google threw this at me, maybe it's a start
Thank you, I found my answer with a mesh collider and Physics.CheckSphere(). Thank you, anyways
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
OnTriggerEnter Not Working 1 Answer
How to get trigger input on an Xbox controller (Mac) 0 Answers
Problem with detecting if instantiated objects are overlapping 1 Answer