Sprite After-image in 2D Game

Godot Version

GODOT 4.3

Question

Wasn’t sure weather to put this in animation or shaders. Anyways:

Edit: I left out very important information here! I want an after image that reflects the player’s current sprite, at that frame.

Something like:
-When speed is over a certain amount
–Create child node (after image)

After image would not be animated, but be a snapshot of the player’s frame the moment it was created.

Here’s a gif that more accurately represents what I’d like! Notice Zero has a greyish after image that reflects his current sprite, then it fades quickly. Not just for dashing either, but for any time he’s at a certain speed.
mega-man-zero-game-boy-advance

This came close but something is missing!

func after_image():
	var current_texture = $Sprite2D.texture
	var after_image = Sprite2D.new()
	# Set the texture and frame of the after_image
	after_image.texture = current_texture
	after_image.frame = $Sprite2D.frame
	# Calculate the frame size and coordinates
	var frame_size = current_texture.get_size() / Vector2($Sprite2D.hframes, $Sprite2D.vframes)
	var frame_coords = Vector2($Sprite2D.frame % $Sprite2D.hframes, $Sprite2D.frame / $Sprite2D.hframes) * frame_size
	# Enable region and set the region rectangle
	after_image.region_enabled = true
	after_image.region_rect = Rect2(frame_coords, frame_size)
	# Set global position and modulate alpha
	after_image.global_position = $Sprite2D.global_position
	after_image.modulate.a = 0.5
	# Add after_image as a child
	add_child(after_image)
	# Wait before removing the after_image
	await get_tree().create_timer(0.2).timeout
	after_image.queue_free()

They probably have a afterimage spritesheet, maybe it’s white and modulated at run-time, maybe the animation goes through colors on it’s own. When rendering the extra spritesheet you could modulate it’s alpha channel/transparency lower and lower for each afterimage-animated sprite, though that doesn’t seem to be the case in this gif.

I see! What about just making after images, and somehow “pulling” the frame the player sprite is on at that moment? Does that seem possible?

I updated my original post, I realize I was jumping the gun with the color changing and didn’t even mention what I wanted! Sorry.

*solved! If anyone is interested I can post

I’m interested, I’ve been wrecking my brain for quite a while over this

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.