I always try and solve everything myself when possible, however this one has me in circles, Ive made a couple of games using Defold but this is the first time ive tried positioning a GUI object based on a Game objects position from within the game, anyways here is my setup and the issue.
My game is setup of multiple scenes that are spawned in using the Factory method, its bascially the same one as the tutorial for the RPG map
On each scene that is spawned in there can be an NPC within the scene / collection, and when my player walks next to him it displays a Chat box I have setup within my GUI, this all works fine, however im trying to get the chat box to display right next to the NPC that I have walked next to and thats were things are going wrong.
I have tried various examples from the docs and other projects but nothing seems to work.
For reference Iâm also not using any camera plugins and have not even added my own camera, im using the built in one defold uses as thats always worked good for me in terms of the zoom, view etc, so if I could do it with that would be perfect before having to go down any plugin route.
The âscreen to worldâ example from the docs looked like it might work for me but that uses a camera added into the game and if possible I need to not do that as ive already built 90% of the game.
Cant believe I didnt know about this, however when I try and add it into my game it doesnt quite position how I would expect, lets say I add the Label next to the NPC (well its sprite), in the editor it looks fine.
However because the GameObjects position is changed within the game the label doesnt seem to move along with it, IE it becomes totally off set to the sprite itself.
The NPCs are being spawned in via a Factory method, and there X and Y set accordingly, the label doesnt seem to stay relative to the sprite.
Hope this makes sense, shame as it would have been perfect
Got them working perfectly thanks, issues I mentioned above was due to me having the wrong âmaterialâ set, I left it at whatever was the default but needed to change it, once I did the labels are displaying perfect.
Thanks saved me a huge headache and will be using them a lot moving forward