New code seems to be not executed or recognized? (print not working)

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

Hello,
i just startet learning Godot and followed a tutourial on Youtube. The Tutorial uses version 3.2.1, I use 3.3.3.
When I changed my Player.gd, with some new code and it didn’t work, so I tried to debug, with print(). But no print() works but the Player can still move, so the code is executed.

#Player.gd:
extends KinematicBody2D
const GRAVITY = 400
const SPEED = 60
const JUMP_POWER = 150
const UP_VEKTOR = Vector2(0,-1)
var movement = Vector2()
var freeze = false
----------------------------------------------------------------------------------------------------------------
func _ready():
    pass 
----------------------------------------------------------------------------------------------------------------
func _process(delta):
if freeze:
	return
movement.x = 0
movement.y += GRAVITY * delta
check_key_input()
check_stomp()
movement = move_and_slide(movement, UP_VEKTOR)
set_animation()
----------------------------------------------------------------------------------------------------------------
func check_key_input():
if Input.is_action_pressed("left"):
	movement.x = -1 * SPEED
if Input.is_action_pressed("right"):
	movement.x = 1 * SPEED
if Input.is_action_just_pressed("jump") && is_on_floor():
	movement.y = -JUMP_POWER
push_error("check action")
if Input.is_action_just_pressed("action") && is_on_floor():
	print("taste gedrueckt und am boden")
	for object in $HitBox.get_overlapping_bodies():
		print("checke objekt: " + object.name)
		if object.name == "Auto":
			object.go_in(self)
----------------------------------------------------------------------------------------------------------------
func set_animation():
if movement.x < 0:
	$Sprite.flip_h = true
	$AnimationPlayer.play("walk")
if movement.x > 0:
	$Sprite.flip_h = false
	$AnimationPlayer.play("walk")
if movement.x == 0:
	$AnimationPlayer.play("idle")
if !is_on_floor():
	$AnimationPlayer.play("jump")
----------------------------------------------------------------------------------------------------------------
func check_stomp():
for body in $HitBox.get_overlapping_bodies():
	if body.has_method("on_stomp") && body.is_alive:
		body.on_stomp()
		movement.y = -JUMP_POWER * 0.75

I searched and tried to find an explanation, but no change of options in the settings neither opening Godot via terminal worked.
Is this problem that can be solved by cleaning the project and how can I do that?

I am happy about every clue you can give!

Could you clarify exactly which parts you added and which parts aren’t working? If you added the entirety of

if Input.is_action_just_pressed("action") && is_on_floor():
    print("taste gedrueckt und am boden")
    for object in $HitBox.get_overlapping_bodies():
        print("checke objekt: " + object.name)
        if object.name == "Auto":
            object.go_in(self)

and none of it is printing, then you might be missing the “action” input binding in your project settings.

CardboardComputers | 2021-08-30 02:59

The new and not working code is:

push_error("check action")
if Input.is_action_just_pressed("action") && is_on_floor():
   print("taste gedrueckt und am boden")
   for object in $HitBox.get_overlapping_bodies():
       print("checke objekt: " + object.name)
       if object.name == "Auto":
           object.go_in(self)

I first had print(“check action”) instead of push_error and got no output, which is the main problem.
It doesn’t matter where I put a print it does not work in this script, but in a the main script it does work.
I have “action” in the project settings.

NessaMithrandir | 2021-08-30 08:32

:bust_in_silhouette: Reply From: NessaMithrandir

Problem fixed:
I found the reason for the problem. The Player, which were in the Level was an older verson of the Player with the old script. Solution: Delete Player which had old versin script and put it back in.

:bust_in_silhouette: Reply From: NessaMithrandir

Problem fixed:
I found the reason for the problem. The Player, which were in the Level was an older verson of the Player with the old script. Solution: Delete Player which had old version script and put it back in.