Need explanation of this code.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Montasir Raihan

Hello everyone. I need an explanation of this code.

func get_button_pos():
return position + radius

This func returns the addition of two vectors, position and radius. Both of them are Vector2(). But I don’t understand how the engine calculates the length of get_button_pos(). Need explanation please.

If you still need something to know, let me know. Thank you.

Montasir Raihan | 2020-12-10 06:57

The length of what? Are you referring to the length of the returned vector?

Ertain | 2020-12-10 17:54

:bust_in_silhouette: Reply From: gamedevshirious

I guess it simply adds x and y co ordinates as it is

return Vector2(position.x + radius.x, position.y + radius.y)

It’s great to know you are curious about internal working of code than just simply copy-pasting :slight_smile:

Hope it helps :slight_smile: