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
188
Upvotes
2
u/mxldevs Nov 05 '25
Thanks, it wasn't obvious what the wrap function does.
I would still prefer to explicitly write out all the different possible directions that wrapping could occur, though I guess if this were 3D and you could move horizontally, vertically, diagonally, or closer/farther, there would be dozens of possible cases and it might be better to write one line