Camera Layer Mouse Position Issue

Hey there! Been awhile, but I have ran into another issue and I have spent too much time on what seemingly should be an easy fix.

Note: The game runs natively in full screen and I use a wide screen, so maybe this has something to do with it.

So I have created a pause inventory screen from an external layout as “GUI” and it is hidden until a button is pressed. This layer has a main graphic that has shows the stat names and whatnot. It also has many text variable display boxes for displaying current stats/inventory count. I also have an animated sprite of my player in the center that will eventually be dynamic in switching of looks and such. I have a temporary box on the side for inventory graphic placement.

I have the base layer centered and the player and zoomed in a little on the main scene.

My external layout has the UI graphics and stat display items laid out perfectly to the scene box and on the correct GUI layer. However, when I press the button in game to call the external layout, I cannot get it to position correctly with the base layer camera. Depending on where I put it, it’s way off the mark.

I have messed with the Center/Origin points at 0,0 and centered/mirrored the camera layers all over the place and can’t seem to get the right combination to make it work correctly. I have played with anchors, but again, I can’t seem to get it to work properly. I just want it to look how it does in the external layout, without stuff moving around.

I also have stat blocks that will display global variables, and a temporary box and that will act as the location for an inventory item graphic, but none of them will stay in the correct position relative to the actual menu graphic.

When I DO get it close, the whole layout seems to duplicate and overlay on top of itself with the other copy offset from the GUI copy.

At first I thought it was the camera smoothing extension, but taking that off doesn’t seem to help.

It’s driving me crazy because all I want to do is to have a popup menu/inventory. It seems like it should be pretty easy. And the only thing stopping my progress at this point is getting these layers working right. No tutorial has been successful at answering this particular question. Please help…there has to be an easier way. I’m banging my head into the wall. Thanks!

That is why you do not place menu/UI objects on SOME position
You place them in some position from the border

For example you have HP bar BUT it is in upper left corner
You place it at let’s say 900 pixels X
Do you think it is same place for me with your wide screen resolution and my not so wide screen resolution?

Instead of placing something at 900 X
You do
Change position of HP bar set to CameraBorderRight()-200

Which no matter aspect ratio or resolution will always be 200 pixels to the left from right border of screen
(remember to run that kind of actions without any conditions so it updates it position)

Same goes for centering
If you want your object to be in dead center of screen you do not put it in some position
You make event like
Change center position of HP bar set to CameraWidth()/2
Which is half of length of camera horizontal distance from left to right border of your camera
Meaning half of screen or just simply saying center of screen

See i made UI buttons for my project
I have 2 in upper right and 4 in upper left
They are not in some position they are moved to some position from left and right borders

Now look what happens when i do this

See resolution of game did change but buttons are in exact same space or distance from their respective borders so to speak

And i guess you are experiencing issue of your objects be perfectly position in external layout
But mess up position when all crap is added to calculate position

1 Like

Ok cool, thank you for that info! So…since I have a whole bunch of objects on that UI, I have to create events for each individual one and set them to a specific X/Y coordinate?

So I did try your method, something is not working right at all. It still is not showing correctly regardless of the screen I test it on. I’ve tried from the center of the image and from the 0, 0 of the image. I’m losing my mind on this.

I did: change the position of the center of “menu” to CameraWidth()/2 for X, and CameraHeight()/2 for Y

I must be plugging something in wrong repeatedly because I really can’t figure this one out. Every time I feel like I’m making progress, something gets in the way lol.

Welcome to world of developer
You solve 1 problem to encounter another 3 new problems
That is the way it is

1st of all show me how it looks in your game or best paste here link to preview
And screenshot of your events

BTW just so you are aware
IF you zoom on that layer it can get messed up

And yes you need to set events for every single object in UI layer to be placed correctly
Option B is to use anchor behavior on object which will stick objects to some borders of screen you select
But i prefer to just go with events while anchor is not bad solution


Awesome, thank you so much! I did end up doing all the placement manually, took awhile but it worked. This has been such an interesting experience lol. I really appreciate your help!

1 Like