Wiggle 2D

Wiggles an element. You can change random offset in code if you are using it on multiple objects and need them to wiggle independantly, just remember to make a new material for each element if doing so.

Shader code
shader_type canvas_item;

uniform float Strength : hint_range(0,20) = 5;
uniform float RandomOffset = 1f;

float random( float seed )
{
	return fract( 543.2543 * sin( dot( vec2( seed, seed ), vec2( 3525.46 + RandomOffset, -54.3415 ) ) ) );
}

void vertex()
{
	vec2 VERTEX_OFFSET = VERTEX;
	VERTEX_OFFSET.x += (
		random(
			( trunc( VERTEX_OFFSET.y))
		+	TIME
		) - 0.5
	) * Strength ;

	VERTEX_OFFSET.y += (
		random(
			( trunc( VERTEX_OFFSET.x))
		+	TIME
		) - 0.5
	) * Strength;
	
	VERTEX = VERTEX_OFFSET;	
}
Tags
2d, bounce, canvasitem, control, node2d, sprite, warp, wiggle
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.
guest
0 Comments
Inline Feedbacks
View all comments