2D platformer drop-shadow/indicator

Hi, I was wondering if it’s possible to have an object that would act like a drop indicator for the player, an indicator that wouldn’t show up if the player isn’t going to fall on a ground (like bottomless pit), it would only show up if the player is on the floor or is going to land on one, and no matter how high the player jumps it would remain in the ground, and if the player is moving, it moves horizontally with him, like in this image:


I couldn’t think of any way to make it

1 Like

I think Raycast could be your solution for this but I never messed with it properly so I can’t suggest a proper solution right now. Check out some of the tutorials and examples regarding raycast, they should help.

Raycast debug view - a game example from the GDevelop game making app | GDevelop

Board walk with raycast - a game example from the GDevelop game making app | GDevelop

This tutorial also shows a bit of raycasting
Create Enemy AI For Your Game - With GDevelop (youtube.com)

This one is also interesting
Ground checking via ray cast | Patrolling character - Tutorial GDevelop 5 (youtube.com)

Oh, I’ve never used raycasting before but it does seem like the most sensical and optimal solution, I’ll try and see what I can do

Okay, I have no idea how to use it, can anyone help

Any luck? Did you managed to figure it out?

Nope, I tried but couldn’t

Hi, I’m sorry for bringing this back up but I still don’t know how to do it and I would appreciate any help with it

Hey 7Elven check the message I sent on your account. Maybe this solution could work

UPDATE: So I looked back at the examples above, particularly the raycast debug view, at first I just took a look and tried to recreate it on my own, but that didn’t work, I couldn’t even get the raycast to visualize, but on the second try, I had an idea to just edit the raycast example, and it was successful, here’s the result:

Although there’s one last issue preventing it from being ideal, so in the game crates break and if the player breaks a crate (it acts like a platform too) the drop indicator doesn’t change its location until the player lands on another platform, now that’s for the crates, if player jumps from Platform 1 to Platform 2, the drop indicator doesn’t leave Platform 1 UNTIL player lands on Platform 2, here’s a video of it:

Best solution for this is probably hide the drop indicator whenever these happen, but I tried to make an inverted condition to hide it and now it’s always hidden, even if the original condition has “show object” in it, any help? This is the only event for it btw, turned out to be simpler than I thought

1 Like

You can add any object that receives a shadow into a group. You can then test for the group. To hide the shadow , you can use a boolean variable.

No condition, Set ShowShadow to false

Raycast, move shadow, show shadow, set ShowShadow to true

ShowShadow=false, hide shadow

You said you tried inverting something. If it was the raycast, inverting the ray cast causes it to pick the farthest object instead of the nearest.

I’m sorry can you elaborate a bit? I only understood having a variable for ShowShadow

You might not need the group. I see it works for platforms and blocks.i thought there was an issue with the blocks but I see now.

You could use this to hide the shadow.

I played around a bit. This would change the opacity and the X scale of the shadow based on the distance from the bottom of the player and the nearest object. The clamp range and ratio can be adjusted.

1 Like

I tried the first one, now it works as intended, I tried the second but I couldn’t really get the change opacity and scale stuff to work, it doesn’t accept the “Y-Player” part, but that’s okay, the first method is good enough for what I wanted to do, thanks a lot!

Player is the name of the object that I used. Y is the variable I used in the ray cast. I capitalized my X and Y mostly because I’m on my phone and it automatically capitalized it.

It’s your project and the choices are all yours. Be good.

2 Likes