I get how to use classes in Python, however, in GDScript there seems to be 3 different ways to use classes: extends "MyClass.gd" class MyClass class_name MyClass, "res://MyClassLocation.tres"

What are the differences in these and what should I use in my use case? I am trying to create enemies for the player to attack, one can run fast, the other is slow but has more health.

Here is how I've used classes for object inheritance in Godot. There might be other, better ways to do it, but it works okay for the games I have released (untested):

Base class

extends Node
class_name Base_Class
# other stuff here

func _make_noise():
	print ("generic noise")

Object_one

extends Base_Class

# example
func _ready():
	print ("This is object one")

# overriding a function
func _make_noise():
	print ("Hello")

Object_two

extends Base_Class

# example
func _ready():
	print ("this is object two")

func _make_noise():
	print ("World")

Hopefully this helps. I think they all ultimately do the same thing, so I would just choose the class syntax that works best for you and your projects.

@TwistedTwigleg If I used the extends "node.gd" format, would there be any differences then just using class_name?

class_name names the class of that file so you can use it later. extends is inheritance, meaning the class named after that is the base class that you can then specialize.

@ZingBlue said: @TwistedTwigleg If I used the extends "node.gd" format, would there be any differences then just using class_name?

I think it would be the same. If I remember correctly, that was the only way to extend classes in older versions of Godot.

3 years later