0 votes

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!

Godot version 3.3.3
in Engine by (20 points)
edited by

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.

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.

2 Answers

0 votes

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.

by (20 points)
0 votes

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.

by (20 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.