-SOLVED-GUI question.

Hi everyone,

Problem:
Ok so I’m trying to upgrade my current GUI, at this time I have multiple objects that move at the same speed values than the player object, which is really cheap and causes problems with colisions.

I came up with an idea to solve it and make a better GUI overall but I’m not sure if I can actually do it.

Idea:

Ok so basicly to resolve this problem I would do the following:

Create an object that’s actually a transparent square, then snap this at the center of the player object ( by snap I mean attach so it moves with it, in a way it’s always “anchored” to the player’s object centre) then I would add the different text objects from the gui and snap/anchor them to this transparent square.

The thing is I don’t know how to “attach” objects to other object’s points, is there a way to do this? If not, what’s the best way to do a GUI that follows the player around NO MATTER WHAT, even if you collide and add force to the player’s object when colliding so it can’t go through another object’s sprite.

Thanks!

I do somehting similar in my current project.

My game character have lots of invisible “sensors” (internally, I called that way) attached to it (feet-land anchors, sensor of water depth, custom hitboxes, a kicker, a pusher, raindrop-reaction surfaces, etc). In this video, the thing moving the fruits like it’s the deer slowly kicking it is an invisible object attached to the deer: https://youtu.be/Pn-W8lrWrI0?t=30

I do it setting specicifc points (pairs of coordinates) in the main character sprite and constantly update the position of every attached object to its point.

Example (I commonly do this at the end of the algorithm [events]):

[code]Conditions:
----nothing----

Actions:
Do X=main_character.PointX(this_attachment_point); Y=main_character.PointY(this_attachment_point) to the position of this_attachment[/code]

I also have all this objects in a group called “invisible” and change that group opacity to zero once at the scene start.

It’s a good idea to configure the origin point and hitbox of every attached object, specially if they have to interact (collide) with other objects of the scene, but maybe you don’t will need so much detail If you just need to display some info above your character. Anyways, I realize the attached objects are more easy to manage if its origin points are configured at the center of the attached object sprite, but in that case you have to design all to work that way (points in the main character, origin points in the attached objects, hitboxes); otherwise, you’ll notice some glitches when rotating or flipping your character.

Important: when you flip or rotate a sprite, all points rotate and flip with it (at least in theory), except the origin point. So don’t attach sensors (or whatever you call this objects for your needs) to the origin point of your character.

Ok, I’m going to digest all that data with my stupid brain, the thing is, the player will change objects a few times, so I cna’t fix tons of objects to another object becuase that’s going to take a lot of work and it’s complicated, but if I could attach everything to a transparent square, I can then just switch this square possition, and all the other objects attached to the square will move with it. That’s basicly the idea.

Ok, so bascily I just create the transparent square, then add points to it, then I fix all the other text objects and stuff to each point and then I attach the square to the player controlled object, and just switch it around objects using variables.

Does that make any sense?

Yeah, you’re organizing it neatly. Sounds great.

Thanks man, I’ll give this a try later today, I’ll probably post back results sometime around 6 AM GMT-3

Uhmm, GMT-3… sos argentino o uruguayo?

Argentino,

Ok so I came up with this:

The position of the guimainframe isn’t updating, it starts at the center of tank like it’s supposed to and all it’s fixed text objects are ok, but it doesn’t move when the tank does. I’ve tried adding a timer so it updates, I also tried moving it to the top of the event list, I’ll keep trying stuff, but if you have any ideas, maybe I could resolve this thing faster.

Thanks!

UPDATE: I have detected heavy amounts of weirdness on this one, it looks like , if I use the the arrows to move it works ok but it doesn’t when I simulate the movement using WASD keys, I’ll keep looking into it.

UPDATE2: even though it works, the guimainframe keeps moving out of screen as soon as my tank collides with an object causing the tank to be moved on the opposite direction, now this should be updating the position of guimainframe to the center of the tank constantly, but it doesn’t apparently.

UPDATE3: bascily I reached the conclusion that, theguimainframe’s position isn’t being constantly updated to the tank’s center.

UPDATE4: I re-read your posts over and over again but I can’t find a way to do what you said:

Do X=main_character.PointX(this_attachment_point); Y=main_character.PointY(this_attachment_point) to the position of this_attachment

I can’t find any actions on the action panel that does this, and there’s no way for me to type it in, so I did the following ( which looks like what you said but it’s missing the X and Y and I have no idea how to add that manually because it won’t let me:

Position-> Position of an object->

Then I set what I needed on the X and Y positions, which left the action looking like this:

Do = tank.pointX(Center);=tank.PointY(Center) to the position of guimainframe

which apparently doesn’t do anything or it’s not updating correctly.

None of this works:

I think you can use layers to do what you want. Open the layer editor and create a new one (you can name it “GUI layer”). Make sure it is above the the base layer (it is by default). Now in the events, when you create a new GUI related object, choose your newly created “GUI layer” as the layer.

By default, the camera is “looking” at the base layer, so everyting that is on the GUI layer will always be displayed on your screen. No need to update any position. I hope it helps!

This may just be a case of using the English spelling of Centre when referring to the point. I seem to remember this has caught people out before. If GDevelop doesn’t understand a reference to a point it sticks the object somewhere off the screen.

Well, mackomando, you just made me look like an absolute, drooling, foolish, dumbass.

Your solution was the most simplest of them all, to think that my current gui was such a mess of events that moved stuff all over the place, and you said " just make a layer" and wow, thanks. You’re the man.

Thanks for your help people.

You made my day. :smiley: Even if it begins lol. I’m just glad I could help you.

I’m curious to see your game. I wish you good luck and I hope you can finish it.