Simple position getter not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chickensandwich
:warning: Old Version Published before Godot 3 was released.
func _fixed_process(delta):
if(get_global_pos(player).x > 1850):
  get_tree().change_scene("res://scenes/map.tscn")

This snippet of code does not run at all. i have tried putting it in func _input and func _process to no avail.

:bust_in_silhouette: Reply From: kidscancode

If you look at the docs for get_global_pos() you’ll see it doesn’t take arguments:

You call it on the node you want the position for. If player is your player node, then you would write:

if player.get_global_pos().x > 1850:
    

Also, note you don’t need parentheses around conditions in an if statement. :slight_smile:

Thanks! im not sure how much this will help though, as my code still doesnt come into effect. ill figure it out

chickensandwich | 2018-01-06 19:25