Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Jayrastaman · Sep 18, 2014 at 03:00 AM · arrayvector3vector2

Vector1, Vector2, Vector3?

Hello -

I am new to C#. I was wondering if anyone would be so kind as to explain to me exactly what a Vector1, Vector2, and Vector3 array(s) are? I see them often in sample scripts, though I do not clearly understand their meaning. I cannot find a clear definition of what these things are anywhere so far.

I read Microsoft DOCS concerning C# - to no avail. Can anyone please assist me in understanding what Vector1, Vector2, and Vector 3 is? And why/where you would use them? I am asking for an explanation in understanding how to use these things in a practical sense. I thank you for your time - Jah bless.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Sep 18, 2014 at 03:50 AM 1
Share

Vector2 and Vector3 are in the Unity docs, not $$anonymous$$SDN.

avatar image knapeczadam · Mar 13, 2018 at 09:43 PM 0
Share

https://github.com/knapeczadam/Unity-Vectors

2 Replies

· Add your reply
  • Sort: 
avatar image
13
Best Answer

Answer by sarthakshah · Sep 18, 2014 at 04:34 AM

Vector2 :- It is representation of 2D vectors and points, used to represent 2D positions, only two axis x&y.

Vector3 :- It is representation of 3D vectors and points, used to represent 3D positions,considering x,y & z axis.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jayrastaman · Sep 18, 2014 at 06:49 PM 0
Share

Just wanted to confirm -

If I were making a 2D game I would use Vector2, right? I'm assu$$anonymous$$g yes, but I want to make sure. Thank you, kindly.

avatar image Eric5h5 · Sep 18, 2014 at 06:57 PM 0
Share

No, you'd use Vector3 for things like Transform.position because all objects in Unity are 3D. Technically you could use a Vector2 for that, where it would be implicitly converted to a Vector3 with a Z of 0.0, but that's slightly inefficient. The 2D physics system, however, is "real" 2D and does use Vector2 for many things.

avatar image sarthakshah · Sep 19, 2014 at 04:24 AM 0
Share

U can make 2d game using Vector3 also, just need to set camera in orthographic mode...

avatar image
11

Answer by Landern · Sep 18, 2014 at 03:00 AM

First, there isn't a Vector1 type in unity, technically if you wanted one it would just be a named float type variable.

Vector2 has a bunch of helper methods for basic Vector2, the same goes for Vector3 and Vector4.

Each vector is a struct, a struct is a value type, when you for instance: create a VectorN(where 'N' is 2, 3 or 4) from another VectorN, you are creating a copy of the original VectorN, and it's fields(Vector2 has x and y, Vector3 has x, y and z and Vector4 has x, y, z and w). If you create an object based off a class opposed to a struct, when you instantiate the object based off another object, that object only copies the reference to the original object you're trying to "copy", this reference points to the same values in each object in memory. If you change one, you change the other, however there are caveats to this.

In Unity 3d mode, GameObjects positions are Vector3, or X/Y/Z, where x is typically the horizontal, Y is the vertical and Z is going through he screen. For a Vector2 which could be used for mouse position(X and Y) or in Unity in 2D mode, the X(horizonal) and the Y(vertical) for GameObjects positions makes complete sense right?

Vector4 is a little more specialized(shaders and such, but Vector3 and 2 are also used), though you can use the Vector structs anyway you desire

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jayrastaman · Sep 18, 2014 at 07:02 AM 0
Share

Both answers helped me understand now. $$anonymous$$any thanks.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# Convert Vector3[] to Vector2[] 3 Answers

Use Rect.Contains to define an area on touchScreens 1 Answer

get the average position of objects in array? 1 Answer

Writing Policy class for handling Vector2s and 3s. 1 Answer

Linking array of sets of vector3's together 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges