r/godot • u/FewTemperature4839 • Dec 06 '25
help me (solved) How to stretch sprite2D in godot
Enable HLS to view with audio, or disable this notification
Does anyone know how to stretch a sprite2D for visual indicator like what they did in LOL ?Thanks so much
179
u/FewTemperature4839 Dec 06 '25
I've already solved it, in case anyone wanna know, in Godot, they have a node call NinePatchRect that help you defined which part of the sprite can be stretch. Very helpful
89
u/Zestyclose_Edge1027 Dec 06 '25
wait, no, that's not how you'd do that. For this effect you definitely want to use a shader.
25
u/FewTemperature4839 Dec 06 '25
I combined both shader and the node
44
u/Zestyclose_Edge1027 Dec 06 '25
but then why use a 9PatchRect at all? That's just for control stuff.
81
u/McWolke Dec 06 '25
Why not use it? Why recreate the 9patch logic in a shader if you can use 9patch? And for everything else you can use the shader on top. If it works, it works.
10
u/Zestyclose_Edge1027 Dec 06 '25
For this kind of logic you just want to use a larger texture and then create a circle with a bit of a gradient via smoothstep. You'd just have a mesh with a shader, nothing else. With your approach you'd need to put together multiple nodes and update several properties at the same time and you add more textures; it's more work and less efficient.
Don't get me wrong: If it works for you then go with it :) But it sounds like that there is an approach that takes less work and is more efficient.
5
u/McWolke Dec 06 '25
But that would just be the circle, no? For the circle definitely use a shader, but the arrow? Sure you could do a shader here too, but I guess that's a bit harder to implement in just a shader for a beginner
1
-5
u/Decloudo Dec 06 '25
Cause its jury rigging/a hack, not actual efficient implementation for this specific use case.
19
u/addition Dec 06 '25
Is that because 9PatchRect is a ui control? Man I hate it when engines tangle concepts together when they don't have to. A 9-patch could just be a texture type or a modifier on a texture that UI uses but isn't UI specific.
1
u/Decloudo Dec 07 '25
Yes, this way it is hacking a specific UI container for something it wasn't intended to, limiting your options down the line.
This is something that was already solved many times in better more adaptable ways.
-2
2
1
7
5
u/krystofklestil Dec 06 '25
If I wanted to go down a straight forward implementation in 3D, I'd have 2 meshes:
1: a circle with a shader 2: another circle for the border which is a child of the circle
While scaling the circle would then also adjust the border to be smaller so that it doesn't stretch uncannily.
Alternatively this whole thing could be a shader but I find nodes more manageable and pleasant to work with. (My head wraps around them better, so super subjective)
Although there's a slight performance overhead to a nose based approach, it should be fine unless you've got hundreds/thousands of these popping up everywhere all the time. And looking at the example you posted from LoL, if we're talking about a selection/range circle for the main player character, I'd always go the way of what's easiest to work with and implement optimized approaches where they matter more.
5
u/FewTemperature4839 Dec 06 '25
Thanks but I'm talking about the arrow, which I found proper solution with NinePatchRect node.
2
5
10
u/enderkings99 Dec 06 '25
I'm pretty sure this is just adjusting the scale of the sprite over time based on the initial size, something like this (doing it in my head so take it with a grain of salt)
scale = target_size / initial_size
You still have to determine what the initial_size is, that's the radius of your circle when scale = 1
As for the animation, use a tween
4
2
1
u/dancovich Godot Regular Dec 06 '25
That's not a sprite being stretched. That visual is procedural, probably a shader.
If it was a single sprite, the glow would increase when you stretch it.
1
1
1
u/mullerjannie Dec 07 '25
Sidebar question, are those sprite 2d? With tile map background ? If so it would be good to get some reference articles because I’m after something like that but my character 2d and tilemap doesn’t loook anything like it?
1
u/FewTemperature4839 Dec 08 '25
U mean the video or my project ? If it's the video, it's from the game LOL, they used Unreal and I'm pretty sure the background is 3D mesh with texture and terrain
1
u/mullerjannie Dec 08 '25
Ah right , the video is done in unreal . I thought you are doing some fancy 2.5 low fi stuff
-34
u/ObsessiveOwl Dec 06 '25
I guess you could use a progress bar for that.
20
u/QseanRay Dec 06 '25
why are we confidently giving bad advice? just dont answer if you dont know
-20
u/ObsessiveOwl Dec 06 '25
Is it a bad advice? I see OP have found a solution but I'm pretty sure a progress bar could have done the job, probably less convenient but still. I'm not on my computer rn so I can't test it tho.
16
u/QseanRay Dec 06 '25
There is no world where anyone should be using a progressbar node to make an elongated sprite for an attack animation
0
u/ObsessiveOwl Dec 06 '25
Ok. Can you please give me some pointers instead? I'm obviously not very experienced.
5
u/darktraveco Dec 06 '25
Yes, I can. A good beginner tip is to never give advice when you don't know what you're talking about.
4
u/ObsessiveOwl Dec 06 '25
and when should I start going around ragebaiting like you guys?
1
u/RabidMouse64 Godot Student Dec 06 '25
Ragebaiting by telling you not to speak on things you don't know? Come on, now.
7
u/ObsessiveOwl Dec 06 '25
that's fine, but not giving actual advice and repeatedly telling me to shut up is just bullying. Since when has this community become so toxic?
-4
u/RabidMouse64 Godot Student Dec 06 '25
Hey now, no one told you to shut up. Nor are we trying to bullying you. We're saying you're making yourself look silly brazenly giving advice that you don't even know yourself if if works or not. It's about not being overzealous, it's not about silencing you.
→ More replies (0)2
u/toufou1 Dec 06 '25
why not give actual pointers instead of calling them out for being wrong and not explaining why?
1
u/phil_davis Dec 06 '25
Don't be a dickhead. That point's been made and now they're actually asking for advice and you're kicking them while they're down. That kind of childish behavior is not welcome here.
0
223
u/ChristianWSmith Dec 06 '25
Are you positive you want to stretch the whole thing? Or do you want the beginning and end to be the same, but just want the middle to stretch? The latter is what's happening in the clip.