0

How can I pin a 3D object to the edge/corner of the screen?

Jasa 1 year ago updated by Elin 1 year ago 1

Hello, I am making a mobile game and want my game to dynamically adjust dimensions, I know that this can be done for UI within the canvas and the rect transform, but I need this function to work on objects. I tried putting objects into the canvas, but as soon as they are scaled to a different aspect ratio they stop working and have no bounds. I dont want to change the camera view, but need the actual objects to change. In my case I want to have walls pinned to the bottom corners of the screen so when the aspect ratio changes the walls will still be in place and objects in the game will be able to bounce off the edge of the screen. What I found online was using the viewpoint system thats given out by the camera, but have no idea how to set it up so the object will transform its position to lock into the corner. 

Tl;dr - Need walls to adjust to the edge of the screen when aspect ratio changes.

Thank you 

Bolt Version:
1.4.3
Unity Version:
2018.4
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

You can do that with screen to wold point.
Bottom left corner is always 0:0
Top right corner is Screen.hight : Screen.width
To get a correct pin you should set the pivot to the corner of the object you want to pin.
If you don't want to have a corner pivot you can add an offset by the bounding size.