-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector3.zero/up/down/etc like in Unity #7317
Comments
Have you tried |
I think it might be useful to have some shorthands for Vector2 and Vector3: Vector2.up # Vector2(0, -1)
Vector2.right # Vector2(1, 0) source: |
i think the code is more readable if such things don't exist
…On Fri, Dec 16, 2016 at 10:31 PM, William Tumeo ***@***.***> wrote:
I think it might be useful to have some shorthands for Vector2 and Vector3:
*eg:*
Vector2.up # Vector2(0, -1)Vector2.right # Vector2(1, 0)
*source:*
https://docs.unity3d.com/ScriptReference/Vector2.html
https://docs.unity3d.com/ScriptReference/Vector3.html
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7317 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z28NvIswnUhid0wbDqiuT1NRRdYZ0ks5rIztogaJpZM4LPt1j>
.
|
The main usage I would see for some of these constants is that they are making conventions explicit. I don't see an usage for Vector3.zero or Vector3.one though, writing Vector3() or Vector3(1,1,1) is simple enough to understand. |
You could always create a helper singleton for yourself, it's obviously not going to be as straight forward, but something like extends Node
const up = Vector2(0,-1) use it as a singleton called v2 It's not a solve all, but it'll help you if you really need it, you might also find out how much you don't really need it. |
Yes and no. They are not making conventions explicit as they are obfuscating those conventions. When you read |
Akien, I don't believe there would be a risk of forgetting such a thing. Even if you do, often it is a simple google search away, is it not? (Also, it should be Reduz, assuming you're saying that the shorthand should not exist, I would like to say that the shorthand will prevent I support the idea. |
Shorthand for simple math is limiting I think. Different projects may have different preferences for directions. So
For a 3D top down space shooter
can be both valid use cases.
|
@hubbyist technically, your 3D FPS example is impractical because up isn't Vector3(0,0,1), it's (0,1,0). You can certainly use this convention, nothing is against it... but the UX in editor won't be optimal because not though this way, I can tell you^^ |
I also support this idea. Even if some projects can use different coordinate convention than the default one, it wouldn't change anything for them as we don't really forcing anyone to use such shortcuts. But for the majority of other projects, it would surely make the code more intuitive and coincise. It can also prevent mistakes and eliminate confusions regarding the coordinate system, especially if you are using an IDE which allows showing a declaration of such constants by clicking them. If some people use a different coordinate system, they can define their own constants or constructing vectors everytime as they've always done, and simply regard (By the way, I think we could remove |
The C# code already has this. I added it in #17134 But this still needs to be added to GDScript. So yes, the "topic:gdscript" label is appropriate. |
I found one additional reason why those shorthands are useful is, their value is tedious to write. Just look at the gesture you do when typing |
GDscript seems to have those too (at least in 3.1), so issue can be closed. |
This was implemented in ba974b8, closing. |
Shorthand for writing Vector3(0, 0, 0).
The text was updated successfully, but these errors were encountered: