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 /
avatar image
0
Question by ThisGuyThatsHere · Feb 06, 2017 at 08:19 AM · rotationpositionspawnscalespawning

Weird offset while Instantiating GameObject

Hi,

So let's say I have this in my code:

 Instantiate (exampleGameObject, new Vector3 (10, 0, 5), Quaternion.Euler(new Vector3 (0, 90, -90)));

Everything works fine, the gameobject is spawned, location is right, same about rotation, but... not enough. About 40% of objects get something weird like scale: 1, 1, 1.000001 or position: 9.999985, 0, 5 and same little problem with rotation. Axis on which this happens and everything else seems random to me, is there a way to fix it? It's really annoying to keep everything perfect in variables instead of using in-world position etc.

Also setting those values later through code doesn't seem to work aswell, percentage is smaller, but still happens.

It's either a very weird feature or maybe my PC just doesn't like even numbers.

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 ThisGuyThatsHere · Feb 23, 2017 at 08:00 AM 0
Share

Bump, that's one critical issue...

avatar image Kossuranta ThisGuyThatsHere · Feb 23, 2017 at 09:34 AM 0
Share

What makes this "critical"? Difference is what one millionth, I can't really think of anything that would be affected by this. Floating point numbers aren't just fully accurate.

1 Reply

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

Answer by tanoshimi · Feb 23, 2017 at 08:25 AM

That's completely normal and expected behaviour, caused by inherent imprecision of floating-point calculations (and rhe additional imprecision of converting rotations from Euler angles to Quaternions). Simply ignore it and carry on.

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 ThisGuyThatsHere · Feb 23, 2017 at 11:13 AM 0
Share

Oh well, this is one real trouble for connection detection... Thanks anyway, gotta play with structs a little.

avatar image tanoshimi ThisGuyThatsHere · Feb 23, 2017 at 12:29 PM 0
Share

If this presents any real trouble for you, there's something wrong with your approach. Floating point imprecision is a property of mathematics - it's not any limitation of Unity.

avatar image ThisGuyThatsHere tanoshimi · Feb 23, 2017 at 01:36 PM 0
Share

it's just, variable stays as it is, but object can be at different position than what I pass and I don't understand the logic here

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

[solved] Get upward orientation of object and add scale value 1 Answer

Calcultate spawn position based on spawn volume's rotation 2 Answers

postion scale and rotation greyed out and not working 1 Answer

Add an offset to the position of an object in front of it 1 Answer

How to Decompose a TRS Matrix? 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