Skip to content

Instantly share code, notes, and snippets.

@DevEarley
Last active February 25, 2025 18:06
Show Gist options
  • Save DevEarley/effc3d20ef021b1c69374574f8369245 to your computer and use it in GitHub Desktop.
Save DevEarley/effc3d20ef021b1c69374574f8369245 to your computer and use it in GitHub Desktop.
Shadow "Decal" script for compatibility mode.

If you are planning on using GODOT in compatability mode, you will not be able to use certain features. Like Decals.

This script will give you a similar effect to decals using a 3D Sprite. There are probably other ways to do this, but this works well for me.

SHADOW file: https://i.imgur.com/BsDkdEY.png

Example setup: https://i.imgur.com/sUOgWMH.png

Instructions

  1. Create a Sprite 3D node and attach the script to it. This script works as a blob shadow for the player. I set the TARGET to the player.
  2. Create a simple shadow graphic. Depending on what you are trying to achieve, you may want to go for a perfect circle. For my game, an oval was best.
  3. Add transparncy via modulation. You can skip this step if your texture is already transparent.
  4. Set to Y-Axis
  5. Under "FLAGS" set the billboard to Y-Billboard.

Notes

  • Make sure your SHADOW node is not a child of the player/TARGET node.
  • If you have any questions: [email protected]
extends Sprite3D
@export var TARGET:CharacterBody3D;
var collision_mask
var height = 999;
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var space_state = get_world_3d().direct_space_state
var query = PhysicsRayQueryParameters3D.create((TARGET.global_position + Vector3(0,0,0)), (TARGET.global_position + Vector3(0,-height,0)) ,TARGET.collision_mask)
var result = space_state.intersect_ray(query);
if(result.is_empty() == false):
visible = true;
global_position = result.position;
else:
visible = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment