How to create play area bounds from UI?
Hello,
I am making a shmup minigame where powerups bounce around the screen, not using physics just bounds checks and direction inversion. The problem is: I also have a UI image control bar at the bottom that I don't want anything to move into; to be treated like any side of the screen currently is. How can I subtract this UI Image's dimensions, converted into world space, from the Camera bounds to use as the new play area?
The UI bar scales physically- it will be the same size on any screen.
Thank you.
are you calculating your bounds in screen space or viewport space? anyway, the RectTransform has GetWorldCorners. you could just transform one of the upper two corner points into camera space and use the y value ins$$anonymous$$d of screen.height or what you're using
Genius. That worked. Thanks so much.
Vector3[] corners = new Vector3[4];
bar.GetWorldCorners(corners);
playBounds.Set$$anonymous$$in$$anonymous$$ax(new Vector3(playBounds.$$anonymous$$.x, Camera.main.ScreenToWorldPoint(corners[1]).y, playBounds.$$anonymous$$.z), playBounds.max);
Your answer
Follow this Question
Related Questions
Screen Dimensions Changing on Input and Breaking UI 1 Answer
How Do I Make the Camera Follow an Escape ship. 0 Answers
Set screen resolution not working with C# 0 Answers
Screen to World Position: Can't seem to get it right 0 Answers
How can I rotate a camera to keep an object within screen bounds? 0 Answers