What is the problem with this code

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

hello,This is my first time asking
This code is for if the player gets out of the map, he will return it
But it doesn’t work, what’s the problem?

func Void():

if global_position.y >= 600:



And how can I attach the code better

:bust_in_silhouette: Reply From: jgodfrey

The main problem here I think is that your function is called Void(). Unless you’re continually calling that from somewhere else in your code it won’t do anything because it won’t be called automatically by the engine. Assuming your 600 pixel value is reasonable for your scene, you probably want to put that code in _process(), like:

func _process(delta):
    if global_position.y >= 600:

Regarding how to attach code, you want to:

  • Paste your code into the forum message
  • Select it
  • Press the { } button in the forum editor’s toolbar (to format it).

Thank you my friend, it worked

mohammad_911 | 2023-01-03 14:45