Basically I’m wanting a system that allows the game to spread a state of an object to other objects (e.g: Fire spreading) BUT only when they are in contact with each other. Logically I would try to make each object check if they are in collision with any object (easy), THEN check if any object that IS in collision with said object has a certain block state to trigger the state change (Hard). But due to how the engine handles logic, I can’t seem to figure out how to do that. So I’m asking if anyone knows how to make this work.
I can’t sleep. It occurred to me that this approach might spread things too quickly. A timer might be needed.
This approach worked well. Much easier than my original idea. I wasn’t thinking about a slow spread.
My test object is larger than my fire object so when it’s positioned over a fire object it collides with the neighbor objects. The Fire has 2 animations. A default and a burn. The fire starts with a touch.
You could use distance instead of a test object. Save the X and Y of the object and then use distance from X, Y is less than a certain amount. I’ve used a plus shaped test object in the past and it was late when I made this.
This is my last edit. A test object is probably easier bc I keep forgetting that there’s no condition to check for distance to a position. You can check for distance between objects but there’s only an expression to check for distance from a position. I guess you could test the X and Y seperatly but a collision is just as easy. It depends on how many objects.
The following probably doesn’t apply but I’ll leave it anyways.
Summary
Sounds like you need something like a Breadth-First Search (BFS). It’s used in things like path finding and flood fill.
Breadth First Search or BFS for a Graph - GeeksforGeeks
It sounds a lot more complex than it is. Unfortunately, it’s late and I don’t have the time to post an example.
You basically use an array as a queue. You place the start position into the array. It could be the position as a structure or an object ID or a text with the X and Y seperated by a comma like “12,23”. I like the last approach bc you can use the array tools extension to split the string back into X and Y.
Anyways, you add the start object to the array. You then use a while event. You get and remove the object position or ID from index 0 of the array. That’s important. The first item.
You then check for neighboring objects. You can use point is inside with offsets if it’s on a grid. Otherwise, you could use collision or distance.
For collisions, I would use a test object. Place it at the position from the queue. Then you add the objects that haven’t been visited and are in collision with the test object to the queue.
You mark the objects as visted or use a structure to keep track of the visited. Bc you want to ignore objects that were already visited.
Preferably, things are done with the object’s positions in a structure and other variables instead of the objects but that depends on your needs, how many objects there are and the size and position of them.
So, it’s basically just grabbing the neighbors, adding them to the queue and repeat until there are no more neighbors and the array is empty.
Believe me. It’s much easier than it sounds.
Thanks, though I kinda found the solution myself after a night of sleep. Here’s what I came up with
I just make sure the box is a few pixels larger than the object itself so overlap can happen. And this allows me to work with other objects in the future for some systemic game design. Thanks for the help though
Very interessant and instructive.
To remember.
Well… Status update on this method. While it works in a vacuum, it starts to fall apart when you add Physics into the game since the “Boxes” do not follow the rotation of the object. Which means my idea ONLY works if the objects are static. So another implementation will be needed if you plan on using physics as well
You could use the sticker behavior to stick the box to the object or the physics weld action if both objects have the physics behavior and you’re using the physics collision condition. Just make sure to test if it already has a box like by checking the animation or a variable to prevent adding additional boxes.
I’ll see how this works
Ok, so it technically works. But it seems like there’s a strange bug that causes the hitboxes to fly off the object it’s attached to when it isn’t suppose to.
(Note: There is no “Unstick” logic anywhere so it should have no reason to behave this way. I think it might be due to how Physics behaves with objects like this
Yeah. I don’t know if the sticker works with physics. Physics has a weld joint.


