[Solved] Text doesn't work properly

How do I…

Make it so when ONE of my sprites are a certain distance from each other, a text shows up

What is the expected result

When ONE of my sprites are red, I want a text show up saying “Building is too close.”

What is the actual result

It only works when ALL sprites are red

Related screenshots

Your biggest issue here, is the “Watchtower distance to Watchtower”. the game is detecting if the watch tower is a certain distance to itself. It would work better if you detect if the towers are colliding instead of detecting distance.

1 Like

if I did that, the Watchtowers would be too close to each other… I want the Watchtowers to keep a certain distance from each other

I don’t want to edit the collision mask either, that would make issues for when I want to implement a way so enemies can attack and destroy it

Imagine this crazy idea
instead of checking if tower is in some distance to tower which is checking itself against itself

How about creating some custom object that would only be like exact shape of your range you want to check
When you pick tower or care to place new one
Now you do not check distance from tower to tower but you check if tower is in collision with that custom object
Of course you need to delete original tower and either place fake image of it on image of your custom object
Or better yet change opacity of picked tower to 254
And you check if tower opacity is 255 and tower is in collision with custom object
This way you can have new or picked tower centered on your cursor and your custom object at the same time while not affecting each other
And now if tower is in collision with custom object
You do not allow to palce new/picked tower
And that is pretty much it

1 Like

so with what i understood, i make a custom sprite wich is the minimum distance the towers can be,

make it so it also follows the mouse when i create a new tower,

and when another tower is in collision with that, i make the text pop up?

And of course put the custom sprite at 0 opacity and make it delete when the tower is placed

Exactly
You do not need that custom object all the time
But only when you are moving one single tower
So you create it when you are moving tower which you either picked or care to place new one
The one that is centered on your cursor you change opacity to 254 heck even to 100 so it looks like is still not there

And now when placing tower while custom object is not in collision with other tower
You delete custom object and
You change your picked tower opacity back to 255

1 Like

okay, I’ll try that and let you know if it works, I’ll also do the opacity thing, it would indeed look better :smiley:

Open it
Click middle mouse button until you see build mode in upper left
now you can place bricks with LMB and remove them with RMB
Actually you can use mouse scroll up/down to change building item

BUT trick is you cannot place new item on existing item
And that is because i have this

I could add another event here where if builder is in collision with items i would tint it to red
Then to 1st event you see here i would need to just add action to tint builder to white

And builder is that cursor you have in build mode

So i am doing here exactly what i told you to do
You could have that custom object always centered on cursor and change its opacity depending on are you moving tower or not

Where you would still need to manipulate opacity of moving tower
Yet you could simply create / delete this custom cursor depending on are you gonna to move/place tower or not

My best tip is go step by step
One thing at time do not try to build whole system at once

1 Like

Where is your origin point. I’m guessing at the base of the tower. If so, then the lower tower isn’t inside either circle. The distance condition is only checking 1 point.

Edit: the points are probably not at the bottom but my logic is still valid.

The objects might be close based on the X value but distance is calculated from the X, Y to X, Y

I agree, a hitbox would be a good solution. You only need to check the object being placed and only when it is being placed. Which would be more efficient.

1 Like

The circles are there only to mean the attack range of the tower, the origin point is the middle of the tower (I think)

I understand the circle is visual but if it’s accurate then the point that is used for distance looks like it might be in the area just outside of reach from each object.

Honestly, I could be wrong. But that’s how it looks to me.

1 Like

Yeah, I might’ve not centered the watch Tower to my mouse well, I’ll try to fix it after I’m done with the initial issue, thanks

1 Like

I made the hitbox, and I did try to make the text show up when the red hitbox is in collision with the watch Tower, but there’s still the exact same issue…

I will edit this as a reply, since I’m a new user, I cannot make more than 10 replies
.
.
.
Everything works perfectly, thank you so much for everyone’s help :slight_smile:
Final result:

1 Like

I am not sure it can be the issue but you can try this

Here

You have collision check in top event and inverted collision check
MAYBE instead of in bottom event having inverted collision check
You make it normal and add there NOT statement
Add condition type NOT in search bar then add it
Shove under it collision check and see does it work now
Opacity check can be above or below NOT statement but can’t be inside of it

1 Like

Going back to your original problem, it’s because of these two events:

The second event overrides the first one until all watchtowers are close together. Get rid of the second event, and just hide May_not_place in an unconditional event before the event that checks the watchtower distance.

I’m not sure if comparing watchtowers compares a watchtower with itself. But use @ZeroX4’s suggestion of having a placing object before you set down the watchtower. It’ll avoid many potential issues.

1 Like

Literally the easiest you could do, is just make the collision masks bigger.