![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | zorua98741 |
I’m writing a function to test the position of a kinematicbody2d (which has a sprite attached) and execute another line of code if it is at x270 (y does not change from 0).
The code goes as follows:
func _process(delta) :
var pos = get_global_position()
if pos == 270:
print("found")
And gives the error in the title (Invalid operands ‘Vector2’ and ‘int’ in operator ‘==’)
I assume this is because “pos” contains 2 numbers, the x and y coordinate, but I’m only testing for x. How can I remove the y coordinate from “pos” or otherwise test for x270 and y0?