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
0
Question by manojpj · Jul 09, 2012 at 10:03 AM · scenecollisionscontact.point

Same scene and object in different levels not giving similar collision values

We created a scene and object for two different levels of our game. Created script for detecting collision. In one case Collision.contact[0].normal.y is giving proper values for the game. But the same script on another level giving a value like 0.9999998 which seems to be a single value which is not expected. Any clue on this?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 09, 2012 at 11:17 AM

All those values are floating point values. A Vector3 is made up of 3 float values. 0.9999998 can be considered as 1.0. This is a general precision problem.

You never should direct compare floating point values, they would almost never match.

So if you want to check if the normal is pointing upwards, just test for a range like this:

 if (Collision.contact[0].normal.y > 0.99f)

It would help to know what you actually want to do. You just described a common, well known phenomenon, so we can't say much more about this without more information.

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 manojpj · Jul 09, 2012 at 11:58 AM 0
Share

Thanks for your quick response.

if (collision.contacts[0].normal.y > 0.7071f){ deleteObject(); }

The code is meant for checking an object collides with another object with less than 45 degrees of inclination. The same code works with other scenes. But it is not working with one particular scene. In all the cases the value getting from collision.contacts[0].normal.y is 0.99998 even though they are colliding at different angles. Anything I can do about this?

avatar image Bunny83 · Jul 09, 2012 at 01:52 PM 0
Share

Ok, this is of course something different. $$anonymous$$eep in $$anonymous$$d that the normal is the surface normal at the collision point. What collider do you use?

avatar image manojpj · Jul 11, 2012 at 06:25 AM 0
Share

One object is using mesh collider and the other object is using sphere collider.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I reset part of a scene? 1 Answer

Addressable for Oculus Go 2 Answers

Scripted Position Handle Not Locking Axis 0 Answers

Camera not showing in scene view 0 Answers

Do unused scripts affect on performance? 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