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 Apr 26, 2017 at 03:18 PM by pdx_matthew for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by pdx_matthew · Apr 25, 2017 at 01:48 AM · math

Incorrect Vector2 values when using the *new* keyword?

Hello, I am using Vector2 structures to track the location of a game piece as it moves between two points in space on a 2D plane.

I seem to be getting very strange values according to the debugger when I initialize my local Vectors. I am pulling two INT values and casting them into local float variables. You can see the values of the respective floats used to initialize the Vector2 named startPosition below in the Watch tab.

alt text

Additionally, I tried using the game piece's transform values to set a 'current' position of the game piece. That seems to produce a Vector2 with what I presume are initial values: alt text

I am really confused by this. In the second example, am I getting this result because I'm leveraging a member structure (transform.position) for a local variable's initialization?

I'm using Unity 5.9.6 on Mac OS X Sierra (ver. 10.12.4) The class that has this code in it is using the following libraries: using System.Collections; using System.Collections.Generic; using UnityEngine;

Any input would be greatly appreciated!

Thank you in advance, Matthew

wrong-vector2-screenshot-1.png (287.1 kB)
wrong-vector2-screenshot-2.png (313.8 kB)
Comment
Add comment · Show 1
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 pdx_matthew · Apr 26, 2017 at 02:09 PM 0
Share

Well it turns out this is probably an issue with the debugger - using Debug.Log() to write the coordinate values to the console, I can see that they appear correct. So I'll close this question as nothing is actually wrong with Vector2 instantiation.

1 Reply

  • Sort: 
avatar image
0

Answer by pdx_matthew · Apr 25, 2017 at 02:06 AM

PS - the build log is clean, no errors, warnings or info messages.

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 pdx_matthew · Apr 25, 2017 at 11:17 PM 0
Share

I am bumping myself. :(

Tried rebooting, no effect. Values assigned to the Vector2 structure appear random each time I run through the code. Perhaps I need to downgrade Unity to a more stable version? Or uninstall and reinstall?

Follow this Question

Answers Answers and Comments

101 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

Related Questions

Predict the hit position 0 Answers

Spawn Objects on Grid - how to define size? 1 Answer

Why does float division not work? 3 Answers

How do I find a point along a line with a forced x and z values 0 Answers

Reading a flowmap with script vs shadergraph 0 Answers


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