How do I create shadows for my top down game?

how do I add the blob shadows to my character that’s commonly seen in 2D top down games , is it something that needs to be drawn directly in the sprite or is it something that can be done using events inside of gdevelop ?
I have also attached an example of how i want the shadows to look.

I haven’t tried this method myself, but I think you could create a separate sprite for the shadow, reduce its opacity, and make it follow the player. Also, set the Z-order of this sprite to be lower than that of the player sprite.

Well that would work for just one object but if I have dozens of objects , I’ll have to make a separate shadow sprite for each object , I was wondering if there could be a better method

Create a sprite for the shadow. Then, assign all objects that can cast a shadow to the “players” group. Finally, add the following events.

  • You need to install the sticker extension.

  • “shadow” is the same as the shadow sprite.

  • In the action I have specified, you can adjust the position of the shadow.

  • You can also adjust the transparency and Z-order of the shadow sprite.

  • In this method, you use a single shadow for multiple characters.

This method worked for me.

I think this should work.

Trigger once under repeat for each works only for one object

This is for creating HP bars above enemies to indicate their HP
But you can totally modify it to create shadows under your objects
Or more like behind them
Just in event where i change position of bar you would do the same but for shadow but also change their Z order to Object.ZOrder()-1
Where object here would mean one to which shadow is linked
So if you link shadows to Enemies yo would change Z order of shadow to Enemies.ZOrder()-1

I did this , first i tried it with trigger once but with trigger once it was only working on just 1 object so I tried without trigger once and now it’s creating the shadow object infinitely for some reason


(Also i haven’t added the opacity action since the sprite already has lower opacity)

That’s strange! In my project, shadows are being generated for all objects inside the ‘players’ group. Could I know which objects are inside ‘shadow2’?

It’s just all the objects on which i want the shadow to be created

Without trigger once it’s creating objects infinitely , I’ve sent a screenshot of the event above too

And you see in my events trigger once?
You exclude objects with linking condition

So 1st do it like i did it and then we will see if it works or not

And if you want to see how it works then press mouse scroll until you get into attack mode
Then RMB to spawn slimes
And LMB to attack
https://zerox4.itch.io/save-load-example-for-gdevelop

The method I proposed works in my project.

1000196982

Hmmm , I think it could be because all the sprites are present in the scene in the first frame , could you try adding the second sprite a bit later and see if it still works

Alright , thanks this method is working perfectly :sweat_smile:

Also, the shadow isn’t being aligned properly to where I want it , how do I make it so that the center of the shadow sprite aligns with the point of “shadowA” of all the objects in the group shadow2 ( I already have the point created in every object where I want the shadow to be created )

There is action to change position but also another to change CENTER position

No, if it’s added later, a shadow won’t be created—unless you change the events like this.

Alright thanks , it works now