0 votes
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.

in Engine by (15 points)

1 Answer

0 votes
Best answer

If you look at the docs for get_global_pos() you'll see it doesn't take arguments:
http://docs.godotengine.org/en/2.1/classes/class_node2d.html?highlight=get_global_pos

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. :)

by (20,917 points)
selected by

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

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.