Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed May 06, 2019 at 03:54 PM by tormentoarmagedoom for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by blendegg · May 06, 2019 at 01:27 AM · vector2

What is the difference between vector2 and position?

Is vector2 simply a container with x and y coordinates, and is there a move function? vector2(10,10)

and why position is can not change x and y as directly? i get error by this position.x +=10 this is ok positon =new Vector2(10,10)

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 Owen-Reynolds · May 06, 2019 at 03:34 AM 0
Share

All variables have types. int Z; says Z is an int. It's like asking the difference between Z and int. "transform.position is a Vector2" is telling you it has an x or y. Also that Vector2 p = transform.position is legal.

transform,position.x+=1 is an error because of a bug in C#. position is a "property" which means your can't reach-through to change past it. Every language has weird "but why not?" stuff like that.

avatar image blendegg · May 06, 2019 at 12:17 PM 0
Share

Thank you I may have understood a little bit

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by tormentoarmagedoom · May 06, 2019 at 11:34 AM

Hello @blendegg

Its simple,

Vector2 is a type of variable, like int, float, bool, string ...

Position is a value of a gameobject (Transform component of an object contains the position value, and rotation and scale)

Position in a 2D world, have 2 coordinates, so a VEctor2 variable is used to define the position. In a 3D world, position is represented as a Vector3 variable (X, y, Z)

Its like, a intensity of a light is represented with a int variable, or a name of an object is represented with a string type variable.

Bye!

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 Owen-Reynolds · May 06, 2019 at 04:41 PM 0
Share

?? light intensity can have a decimal point. It's a float.

avatar image
0

Answer by Lightning_A · May 06, 2019 at 02:02 AM

I'm probably not the best person to answer this question since I'm also pretty new to Unity and C#, so if I'm wrong, I'm sorry, someone correct me. My understanding is that a Vector2 is essentially a variable that stores 2 values, and the position is a vector (I think it's actually a Vector3 which stores 3 values because Unity is a 3D program, though if you're making a 2D game the z axis isn't super important) that is automatically created for game objects in your scene. I don't think you can edit it using the position vector, I believe the position vector is just there for calculations. For movement functions I think you can use Transform.translate (or whatever other transformation you want to do), but I think the preferred way to do it is by applying forces with rigidbodies (which are used for physics). For a better answer I'd look up some tutorials on 2D player movement, I'm sure there's plenty of great ones.

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

105 People are following this question.

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

Related Questions

What are the parameters passed in vector2? 0 Answers

Lerp a vector2?,Lerp a Vector2? 0 Answers

C# How can create a list of floats from different types of structs? 0 Answers

Get vector2 coordinate from one object to another 0 Answers

How to create a Knockback vector2 directions script (c#) 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