Breakpoint can't change why and change anything about it

Godot Version

4.2

[

extends Node3D
@onready var animation_player = get_node("AnimationPlayer")


var Current_Weapon = null

var Weapon_Stack = []

var Weapon_Indicator = 0

var Next_Weapon: String

var Weapon_List = {}



@export var _weapon_resources: Array [Weapon_Resource]
@export var  Start_Weapons: Array[String]


func _ready():
	Initialize(Start_Weapons)
	
func _input(event):
	if event.is_action_pressed("weapon_up"):
		Weapon_Indicator = min(Weapon_Indicator+1, Weapon_Stack.size()-1)
		exit(Weapon_Stack[Weapon_Indicator])
		
	if event.is_action_pressed("weapon_down"):
		Weapon_Indicator = max(Weapon_Indicator-1,0)
		exit(Weapon_Stack[Weapon_Indicator])


func Initialize(_start_weapons: Array):
	for weapon in _weapon_resources:
		Weapon_List[weapon.Weapon_Name] = weapon
	for i in _start_weapons:
		Weapon_Stack.push_back(i)
		
	Current_Weapon = Weapon_List[Weapon_Stack[0]]

func enter():
	animation_player.queue(Current_Weapon.pullout_Anim)
	
	
	
func exit(_Next_Weapon: String):
	if _Next_Weapon != Current_Weapon.Weapon_Name:
		if animation_player.get_current_animation() != Current_Weapon.Pulldown_Anim:
			animation_player.play(Current_Weapon.Pulldown_Anim)
			Next_Weapon = _Next_Weapon
	
	
func Change_Weapon(weapon_name: String):
	Current_Weapon = Weapon_List[weapon_name]
	Next_Weapon = ""
	enter()


func _on_animation_player_animation_finished(anim_name):
	if anim_name == Current_Weapon.pulldown_anim:
		Change_Weapon(Next_Weapon)]

Question

i get this breakpoint when i try to use the input weapon_up its got to do with the
(if animation_player.get_current_animation() != Current_Weapon.Pulldown_Anim:) line and then at ( exit(Weapon_Stack[Weapon_Indicator])) ive tried changing animation names

Please, fix your post formatting by enclosing your code in ``` like so:

```gdscript
[your code]
```

What do you mean “breakpoint”?
Do you mean an error? If so what is the error you are getting?

breakpoint


its saying its invalid i checked like 50 times renamed both things and still doesnt do it

first it said breakpoint then it switched to this now its breakpoint again

A breakpoint is a point in code that pauses execution of that code for the purpose of debugging.
The coder (you) put breakpoints in.
There is more than one way but most likely you put them in accidentally by click on the column left of the line numbers (where you see the orange arrow in the pic).
If you look at the code when it isn’t running you will see a red dot there.
Click on that dot and the breakpoint will be removed.

The “invalid get index” error is telling you that the object in the variable Current_Weapon does not have the property Pulldown_Anim

Check your spellings, capitalization, and if they are correct then post the code for Current_Weapon

1 Like

Yeah, post the code for your Weapon_Resource resource.

thank you soo much bro you actually explained everything unlike others

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