Center a text object


I have this attack the player does, and when it collides with an enemy, I want the text to show up on top of the enemy

I want the text to spawn relevant to the enemy’s width and height. However, when I create the text, I get this instead

Y angle appears to be working, but the X angle does not (Especially noticeable for the wider enemy).

I also tried to spawn it using enemy.Width()/2, with just the same results. On top of that, I’ve noticed that even though I want the text to spawn at the enemy’s “center,” it instead spawns at the enemy’s origin point instead?

Does anybody know how to make the text appear center and above an enemy, no matter the height like what you typically see in games?


Add new point in the enemy and position it above the enemy example x=16 y=-10.
Then position the center of text object to that new point.

I believe that the “Center” point is capitalized (if using the default one), so you may want to double check because “center” and “Center” are seen as two different locations, so if it’s looking for “center” it’s not there and therefore positioning it at enemy (0,0)

Thanks, capitalizing center worked, but now I have another problem:

Now the text object ITSELF is uncentered. The text object is centering it’s origin point on the enemy center point.

Is there a way to make the text’s CENTER point spawn on the enemy’s center instead of the ORIGIN?

Does the dmgText field have the word “Damage” in it already, or is the text being updated when created?
I have had a few issues like this too, there may be another way, but what I have done is create the object at an off-screen location, then position it to (in your case) enemy.X(“Center”)-(dmgText.Width()/2), because without the object being created it does not seem to be able to determine the width of the text object until after creation. So I don’t know if that would help, but maybe give it a try and see if you get your text pos correct.

Ohhh, you mean like an object repository? Like what Construct 3 does? That’s clever.

Although, I added a text object to the scene, and nothing happened. The object is still stuck in the same spot as before when it’s created (I decided not to change the position of it because I want it to be created)

Anything else I can do?

Use this:
You can spawn it any where and update the position.

Alright, I’ve added the positions, and the text still insists on spawning from it’s origin point, although, I did get it close enough to the center that it’s not very noticeable because of this, so thanks for both of your help ^^