Breakpoint reaches function but it's not executed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MateuS

It’s very weird, but even though the call to the function is reached with a breakpoint, the function is not executed. Here’s the code:

  func _spawn_player(is_master: bool, is_ai_player: bool, id: String, name: String, character_index: int, faction: int) -> BaseCharacter:
    # ...
    
    player.call_deferred("initialize", id, name, character_index, texture, num_characters)
    
    _handle_player_group_and_change_pos_if_necessary(player, is_master, faction)

    # ...
    
    return player
    
    
func _handle_player_group_and_change_pos_if_necessary(player: KinematicBody2D, is_master: int, faction: int) -> void:
    print("ESCAROLA")
    if Client.game_mode != Client.NO_ALLIES:
        match faction:
            Client.PIRATES:
                player.add_to_group("pirates")
                if is_master:
                    player.position = get_random_pirate_spawn_pos()
            Client.ZOMBIES:
                player.add_to_group("zombies")
                if is_master:
                    player.position = get_random_zombie_spawn_pos()
    else:
        player.add_to_group("teamless")
        if is_master:
            player.position = get_random_teamless_spawn_pos()

As you can see, i call the _handle_player_group_and_change_pos_if_necessary from the spawn_player function. Here I put a breakpoint and the game stops when it reaches this point. Twice, because I spawn 2 players.

But then, I put 2 more breakpoints, one in the if and the other in else of the _handle_player_group_and_change_pos_if_necessary function. Well, the program does not stop on these breakpoints even once. The text in the print function is also not showing in the output. It’s like the function is not being called at all.

My game has 3 modes, and this only happens with 1 mode. It seems relevant, but according to the breakpoint, the game should call the function in this game mode too.

I’m confused and I don’t know what to do, it does not make any sense to me. If the breakpoint reaches the function call, why is the function not being executed? Please, help me, I have no idea how to solve it.

PS: I don’t get any errors or warnings, the function just feels like it does not want to execute

If I replace the function call with the code, it works. But why?! Can someone explain what’s happening?

MateuS | 2022-08-05 05:23

:bust_in_silhouette: Reply From: MateuS

ᯣ.ᯣ. I was overriding the function in another script. I didn’t remember I created a subclass