Keeping UI in place when camera is manipulated (almost works)
MentalDonkeyGames
Member Posts: 1,276
I have a little problem with keeping my UI in place when i manipulate the camera.
I got it working when the camera is spinning and when the camera is stretching in a weird way, but when the camera spins and stretches at the same time, it´s not working.
I made a sample project to show the issue.
In the game attributes:
Turn on SpinCamera -> hit preview -> everything works.
Turn SpinCamera off and StretchCamera on -> hit preview -> everything works.
Turn both attributes on -> hit preview -> The gear icon does not stay where it should.
I´d really appreciate if someone can figure this out for me. I just don´t know what i should add to the expressions.
Comments
Have you tried turning scrollable off in Scene -> Layers in the inspector?
Lump Apps and My Assets
The issue is that the camera is not maintaining a constant ratio, and you'd need to factor this into the cog's positioning maths - you can check this out by changing the camera controller's Height constrain behaviour to . . .
scene.Camera.Size.Width / 1.775
. . . which locks the cog into position.
Thank you @Socks. I didn´t think of that... I´ll try to figure it out now.
Mental Donkey Games
Website - Facebook - Twitter
Almost there...
I added this to the Y constrain of the cog.
Now it only moves up and down, so i´m halfway there.
I´m no math genius, but i assumed i should add the same calculation to the X constrain (it make sense to me...), but for some reason, it does not work.
I also tried "reversing" the calculation for the X constrain like this
I also tried reordering the calculations in multiple ways, but no luck...
So... How should i calculate the aspect ration in the X constrain?
Or should i edit the Y constrain somehow?
Mental Donkey Games
Website - Facebook - Twitter
Did you try the suggestion I posted above ?
Yes, but it keeps the aspect ratio the same. I need the camera width and height to change like they do in the demo file i posted. I just need to figure out how to calculate the changing aspect ratio in the gear actors constrains so it stays in place.
Mental Donkey Games
Website - Facebook - Twitter
Does anyone have any ideas?
Mental Donkey Games
Website - Facebook - Twitter
Yeah, the maths is a little fiddly but can be done, it just takes some exploration.
I'm losing my mind!
I'm pretty sure the Y constrain is right, but i can't get the X constrain right no matter what i try.
Does anyone know how to fix this?
Mental Donkey Games
Website - Facebook - Twitter
I still haven´t figured it out, so one more bump for this...
Mental Donkey Games
Website - Facebook - Twitter
You might need to ask some specific questions - and explain what the individual parts of your equations are doing.
@Socks i´m not good at explaining stuff, but i´ll try...
Here´s the constrains for the gear actor. Top is for position X and lower is for position Y.
Now if i switch StretchCamera to true and SpinCamera to false in the demo file i posted, the gear stays in place.
Now, when i also switch the SpinCamera to true, the gear does not stay where it should. It goes up, down, left and right.
So as long as the camera rotation is 0, the expressions work perfectly even when the camera aspect ratio changes.
If i add this to the Y constrain:
The gear stops moving sideways, and only goes up and down anymore. (so i´m assuming it´s set up right now...)
I´m out of ideas on what i should do with the X constrain to keep the gear in place. Or if i should try a completely different approach on this...
Mental Donkey Games
Website - Facebook - Twitter
Last bump before i give up... I might need to remove this camera effect from the game if i can´t get it working,
Mental Donkey Games
Website - Facebook - Twitter
@Socks is there something i didn't explain right? Or is there something i need to explain more?
I'd really appreciate some help with this.
Mental Donkey Games
Website - Facebook - Twitter
Not really got the time to work through this, it is perfectly possible, I've done it before a few times but it does take time.
Ok, thanks anyway. I'll try to figure it out.
Mental Donkey Games
Website - Facebook - Twitter