Can you Rename the AnimatedSprite2D section of your code for organization.

Godot Version 4.7.2 Stable windows 64

In the built in Godot script editor can I change the function variable AniamtedSprite2D to something else, for example if I have a slime enemy and I am editing the code, can I isntead change the call function for the class from animated_sprite_2d to slime? is that possible in Godot.

Thank you

extends Node2D

const SPEED = 60

var direction = 1


@onready var ray_cast_right: RayCast2D = $"Ray Cast Right"
@onready var ray_cast_left: RayCast2D = $"Ray Cast Left"
# Slimer Animiation flip


@onready var slimer_body: AnimatedSprite2D = $"slimer body"

Can you specify what you’re trying to do? Or at least rephrase your question? I don’t really understand what your goal is here.

it’s possible if you created custom class that extends animated sprite 2d, you must create new scene that is animated sprite 2D and call it Slime, then add script (best to call it slime too)

inside script you do:

extends AnimatedSprite2D
class_name Slime

## Slime's code

and when you put your new packed scene into the tree you can do:

@onready var slime1: Slime = $"slime1"

Sidenote - if you don’t want static typing to take so much space you can do:

@onready var slime1 := $"slime1"

and it will automatically assing Slime type o slime1 variable as long as slime1 node is of type Slime

This is it, I didnt know you had to directly use the extend command or that it even existed everywhere I googled just said to do the animatedsprige = name command but this worked. Thank you so much.