Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Creedd910 |
usually if body.name works to collide with other players but its give me the error “The identifier “body” isn’t declared in the current scope” it ususally works but its not.
if Input.is_action_pressed(“p1_push”):
if body.get_name() == “Player_1”:
body.hit_by_enemy()
can someone help
Where does body.get_name()
work for you? I think one of the possibilities is that the “body” variable is exclusive to a collision function triggered via a signal (e.g. body_entered
for Area2D). It would, in that case, work within body_entered()
, but not the other functions.
Ox0zOwra | 2022-08-05 13:16