How to make block have a fifferent animation if another block is above it?

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

I am making a one-block/terraria game, and i want grass to look like dirt if there is any block above it.

What is the expected result

It should look like dirt if any block is directly above it

What is the actual result

All blocks look like grass.
(also, i have multipe frames for each animation, so i use a random frame within the range of that kind of animation)

Related screenshots

here is the events related.

the animations

Thanks for any help,

Hello, Inusitatus

When using the condition “Trigger Once” with the “Repeat for each instance…” event, the condition will cause the actions to occur only once in a single instance. Maybe that’s the problem. You can remove the “Trigger Once” condition and use a boolean variable or maybe inverted conditions that check animations to replace the trigger once function.

Thanks @Rasterisko for replying.

What exactly does that mean?
Do you mean add conditions to check the animation instead of trigger once?

I mean you need remove the condition “Trigger once” and change for another condition that can make your event runs only one time. I’ve made an example:

My object have 3 animations:

When the rock collides with it, it will randomize between the last two animations. Using trigger once, only the first instance will change the animation.


Now, I removed the trigger once and I put a condition checking if the animation number is less than 1.


Which conditions are best for changing the trigger once depends on your game. But I hope the example has clarified a bit.

Edit.: just to reinforce this “problem” just happens when you use the Trigger Once with the event “Repeat for each instance…”
Here’s a thread about it that I tried to explain in a more elaborate way: "Trigger once" with "Repeat for each instance": different result than expected

the way i have it

never even tries to change it to dirt, which is where im getting stuck.
here is demo


i have these events using an extention from here, only works on first instance still ):

I could be wrong, but I believe your problem is related to the fact that you are checking if the point is inside of other instances of the same object. :thinking:

In your edit2 you are using another object to check the collision… I think you should take into consideration what I said about Trigger Once and try to replace it.

Oh, yeah, I made sure that the little sensor objects hotbox would stay out of the linked object
edit: i did what you said about replacing it and it still doesnt work(perhaps i shouldnt use the extention for that)


I’ve never used this extension. I sent you the link to show my explanation and not have to repeat it. :eyes:

You’re changing your events a bit fast and I’m not familiar with these checks. But what I told you about using Trigger once will be necessary, even if it’s not enough to solve your problem. Maybe someone with more experience than me in these checks can help you with this part. I’m going to do some testing and if I find something that works I’ll bring you here.

Yeah, im honestly not sure what im doing at this point, im just trying things to see if they work. ):

Is there any chance i can use raycasting?

It probably wouldn’t be good for your performance since it would be a lot of blocks.

1 Like

Here are 2 ways. One uses the for each and the other checks as an object is added. I used mouse released for testing. The event levels (indentation or subevent structure) are extremely important.

I used a text variable but a number can be used. It’s all in the level or pick lists. Without any conditions all objects are basically picked. When you add an object or use a point inside or for each object just 1 object is picked.

In my examples, it sets the location to x and y and sets a default animation. It then picks all objects and checks for the point. If the point is inside it changes the string to another value.

Since the next event is at the same level or indentation, it goes back to the previous pick list. Which is the original object either the for each object or the just added one. The list is remembered for each event and subevent or previous event.

It can be confusing but the key is to pay attention to the pick list. I like to think of conditions like filters.

The problem with point is inside is that it picks the object above the target object. Any action would apply to it.

There’s a similar problem with the link technique. The pick linked object picks just the linked object. So, the it can only test against that one object.

That technique might work if it checked the point is inside for the other object x, y first, set a variable and then use a picked all objects and then pick the linked object. Then similar to my examples, used the variable to decide the texture. It could be a texture or a boolean. Whatever you prefer.