Unity getting wrong transform.position from level image when trying to clamp camera within level image
Hey guys,
We're setting up our first Unity project and running into some issues when trying to clamp the camera within the level image(We don't want the camera.transform.position(it's world position) to travel outside of the levelImage.transform.position(it's world position).
However, when writing the code for this, it clamps the camera within it's own local x and y, not the level's x and y. Can someone please point us in the right direction on how to get this set up right? Please check out the attachments for details. Thanks guys! ![alt text][1] [1]: /storage/temp/55456-levelscene-sample.png
I'm quite confused with this... I may be wrong about this, but it seems to me that you think that transform.position is at the bottom-left of each GameObject, whereas it's at the center of each GameObject. If this is not the case, then I'd need some more info to understand what's happening.
I see, that makes a bit more sense. How do you keep a camera from going outside the bounds of the level if you can't translate it by setting the position of it's rect(x,y,width,height) in Worldspace? None of the answers I've seen on the forums make any sense. I'm co$$anonymous$$g from SDL2 where you can position objects in relation to each other easily based on pixel coordinates. Let me know :)(I'm working on the code with glorenzen93)