Godot Version
Godot 4.3
Question
Just want to preface this by saying this is my first godot project. Anyway, I wrote this script for an npc in my game and none of the functions run when I run the project. I tried putting print statements in all of the functions to check where it breaks, but literally nothing even runs.
extends CharacterBody2D
#var characterColors = ["ANTIQUE_WHITE", "BEIGE", "BISQUE", "BLANCHED_ALMOND", "BROWN", "CHOCOLATE", "CORNSILK"]
var firstNamesMale = ["Aldric", "Alistair", "Aric", "Baldwin", "Berengar", "Branislav", "Cadeyrn", "Cedric", "Dorian", "Endric", "Eric", "Godwin", "Faelan", "Faramond", "Garrick", "Harold", "Lucian", "Oswin", "Roland", "Piers", "Sigmund"]
var personName := str(firstNamesMale[randi_range(0,len(firstNamesMale)-1)])
var maxHealth := randi_range(5,10)
var currentHealth := maxHealth
var strength := randi_range(1,5)
var speed := randi_range(1,5)
var age := randi_range(12,24)
var level := 1
#var color := str(characterColors[randi_range(0,len(characterColors)-1)])
func _physics_process(_delta):
print("Physics Process")
move_and_slide()
print("Moving")
if velocity.length() > 0:
$AnimationPlayer.play("Walk")
if velocity.x > 0:
$Sprite.flip_h = false
else:
$Sprite.flip_h = true
func _input_event(_viewport, event, _shape_idx):
print("Input Event")
if event.is_action_pressed("click"):
$InspectorMenu/NameLabel.text = str(personName)
$InspectorMenu/HPLabel.text = str("HP: " + str(currentHealth)+"/"+str(maxHealth))
$InspectorMenu/StrengthLabel.text = str("Strength: " + str(strength))
$InspectorMenu/SpeedLabel.text = str("Speed: " + str(speed))
$InspectorMenu/AgeLabel.text = str("Age: " + str(age))
$InspectorMenu/LevelLabel.text = str("Level " + str(level))
$InspectorMenu.show()
func _process(delta):
print("process")
Here's a screenshot of the scene. The dudes are the npcs with the script on them The NPC's are just a characterbody2d with a sprite node, collider, etc. attached and the script is on the characterbody2d node.