Open EchoingLogos opened 2 years ago
Feels almost needless to say, but should there be an actual implementation, the implicit "float" casting should be possible for Rect2, Vector3 and Vector4. It doesn't help the case that a lot of the codebase accepting generic Variants is very strict about Types, with the most common exception being INT and FLOAT themselves.
I'm also annoyed by Vector2i stuff. When we create grid based game using tilemap, such the calculations frequently occur. It should be casted implicitly
This would be much appreciated indeed.
Maybe add a warning message similar to truncating an integer (when assigning Vector*
to Vector*i
), but not an error.
I have a lot of cases where using vector2i would be better but because of this behavior i just use regular vector2's instead. I'd rather have slightly less assurance of integer vector2's than having to write ugly casts everywhere. I'd be very happy if this gets changed so I can start using them
Describe the project you are working on
A tile-based game which constantly deals with both types of vectors.
Describe the problem or limitation you are having in your project
GDScript allows for arithmetic between integers and floats other than with the modulo operator. I believe it makes sense that this behavior is kept for both types of vectors. It's not entirely trivial to determine whether a function will return a Vector2 or a Vector2i. Ensuing errors are only mildly annoying, but happen quite often and break focus.
The existing behavior between the float and integer types seems to contradict the behavior between Vector2 and Vector2i.
Further, current behavior seems to have Vector2 implicitly floored and casted to Vector2i when assigned to a property typed as Vector2i. This is inconsistent with operators == and != not allowing the two different types.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
For instance, the following would all be legal:
If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around with an explicit cast, but it will happen often.
Is there a reason why this should be core and not an add-on in the asset library?
N/A