I was surprised to see that when passing float arguments to instantiate a Vector2 class we don’t need to enforce floats by using a decimal point i.e. Vector(25.0,0.0). Obviously Godot must convert to float as required.
its probably good practice and more readable for yourself, if its something that you have done in the past.
but, yes as far as i understand it, the Vector2 arguments are automatically cast as floats by the constructor.
nice spot and highlighting
I spotted it because the video highlights the need for specifying floats with the Print command to get a fractional result. However, I can see why it would be needed in this case because we may want either an integer or float result displayed. Therefore it makes perfect sense that for functions that don’t return numerical results that they cast arguments as required. It’s having used C/C++ where it’s required to be more explicit, but Godot is more forgiving and easier!
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.