Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Pheonyxior |
I’m following the Tactical RPG GDQuest course and I see this func :
func calculate_map_position(grid_position: Vector2) -> Vector2:
return grid_position * cell_size + _half_of_cell_size
I don’t understand what’s going on in the arguments. Why “grid_position: Vector2” ? If the func takes a Vector2, shouldn’t it be just written “grid_position” ? And, it’s not a default assignement right ? default should be written with “=”, and it should be a value not a type. And then why does after the parenthesis’s closed there’s “-> Vector2” ? It’s not an argument, I didn’t even know you could write stuff after passing an argument, so what is it ? And why is it Vector 2 ? My guess is that it’s all to make sure the taken value and the return value are both Vector2 no matter the case, but I don’t know for sure, I don’t know what I’m actually telling the computer to do, and I can’t find any info in the Docs or FAQ or Python synthax it’s so frustrating ! >_<
I thank you in advance for any info you can share regarding my questions and/or for pointing me to where I should be searching when looking for this kind of information :).