Guys can anyone explain why this doesn't work?

Godot Version

v4.2.2.stable.official [15073afe3]



1 Like

_on_body_entered is called only in the frame, when the body is entered.
Input.is_action_just_pressed evaluates, if in the current frame the action ui_accept was just pressed.
So print(food) is only printed in frames, where the following conditions are true:

  • the body is entered and
  • the action ui_accept is pressed and
  • the action ui_accept was not pressed in the previous frame

So you would have to press ui_accept down exactly at the same time as the body is entered, for print(food) to be executed.