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
1
Question by Persona · Nov 10, 2012 at 10:48 PM · transformarraypositionvector3ngui

NGUI - Vector 3 Position different from position

I've been trying to set a vector3 position in a new array and set the positions in code, yet when I have a transform object move to the location, it jumps to a different one:

 public Vector3[] mousePosition;
 
 mousePosition = new Vector3[2];
 
     mousePosition[0] = new Vector3(0.0F, -37.0F,0.0F);
         fieldmouse.transform.position = mousePosition[0];
         


I'm using C# and just don't get it. The code should set the Y position to -37. Yet the transform is suddenly at -6735 instead.

Comment
Add comment · Show 3
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 IronFurball · Nov 11, 2012 at 12:10 AM 0
Share

it works when i try it in a new C# script, perhaps you can provide some more information, such as what is fieldmouse exactly? i simply set it as a cube gameobject and it works.

could you post your entire script ?

avatar image sparkzbarca · Nov 11, 2012 at 01:27 AM 0
Share

im freaking awesome if this solves it by the way.

-37 is 37 meters or a really long ways below the terrain height which is 0.

Your mouse is below the terrain and if your field mouse has a rigidbody with gravity enabled it is freefalling until it arrives at whatever unitys editor rockbottom is?

avatar image Persona · Nov 11, 2012 at 06:18 AM 0
Share

No, it's a sprite powered by NGUI, so I'm guessing the problem lies there.

1 Reply

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

Answer by whydoidoit · Nov 11, 2012 at 06:13 PM

With NGUI you need to use localPosition - global positions are all screwy because of the number of scaled parents that NGUI uses. Basically NGUI objects are placed on pixel boundaries - but your global position is just some real world thing.

Try settings the localPosition instead.

Comment
Add comment · Show 4 · 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 whydoidoit · Nov 11, 2012 at 06:14 PM 0
Share

Be aware that the position you see in the inspector is the localPosition.

avatar image Persona · Nov 11, 2012 at 06:20 PM 0
Share

I tried the localPosition with no success. Like whydoidoit said, that number in the inspector is the one off.

avatar image whydoidoit · Nov 11, 2012 at 06:30 PM 1
Share

If you do this:

  fieldmouse.transform.localPosition = mousePosition[0];

The the number in the inspector should read: 0.0F, -37.0F,0.0F

avatar image Persona · Nov 11, 2012 at 07:02 PM 0
Share

I ran a debug.log to get a print out and that's correct. It seems like the problem is located when it's forced to move. I've figured out a solution.

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

13 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

Related Questions

Storing transforms from objects in Array 1 Answer

How do you get the vector3 of one object and assign that vector3 to another object? 1 Answer

How to smooth movement object in one-axis? 1 Answer

Why are my player's positions not being set correctly? 1 Answer

Problem with local position 3 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