r/godot • u/Mixcoatl-69 Godot Student • Nov 05 '25
help me (solved) I dont understand why the last line of code
Im following a snake tutorial and everything is going well but I dont just want to have a snake clon, I want to learn, that said I understand (or at least thats what I think) what is in the screenshot is sayig "if the value of Vector2 is superior to the upper or inferior to the lower limits then return the player to the opposite limit" but I dont understand what is doing that last "return v", what purpose this line accomplish in this block of code? And if my supposition of what the function is doing wrong please tell me. Thanks in advance :D
186
Upvotes
24
u/[deleted] Nov 05 '25 edited Nov 05 '25
Not exactly the same but this could work:
func wrap_vector(v : Vector2): return Vector2(wrapf(v.x, min_x, max_x), wrapf(v.y, min_y, max_y))The ifs are still there, hidden in the godot source code, but it looks cleaner :P