Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Feref2 · Mar 21 at 01:55 AM · collision detectionfloatprecisionsweeptest

Am missing collisions thanks to floating precision.

I was originally using a sweeptest, but am not right now. I coded my own collisions from scratch, but they work essentialy as a sweeptest. I just have one issue (that happens with the sweeptest as well): because of floats' imprecision, sometimes I miss collisions if the character keeps moving after colliding with a wall. I tried solving this problem by moving the character in the opposite direction before doing the sweeptest, and it works, but that causes other problems (like accidentaly colliding with thin objects behind you). So I decided that the best option was to simply have an offset between the wall and the character, always a small distance imperceptible to the eye but big enough to register the collisions. The problem is that my code isn't working. Look, am not going to show my full code because it´s too long and honestly you won't read it, but am not asking for anything that doesn´t work with a simple sweeptest (so do that if you need to). The only thing that am doing besides that is this: float hitDistance = movement.magnitude * closestT; (movement is the displacement vector and closestT is a float that ranges from 0-1. It's basically the collision time). Then I do this: movement = movement / movement.magnitude * hitDistance; //and then I just translate the object the movement.

So, is there an efficient way to create a small gap between the wall and the character? I was trying this: hitDistance = movement.magnitude * closestT - smallOffset; but obviously doesn´t work.

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 Feref2 · Mar 21 at 01:56 AM 0
Share

I don´t know why, but Unity answers isn´t registering some of the multiplications. Is hitDistance = movement.magnitude by closestT; and movement = movement / movement.magnitude by hitDistance.

avatar image Eno-Khaon Feref2 · Mar 21 at 02:52 AM 0
Share

Part of the Unity Answers markup syntax includes italicizing text between single asterisks (*). For example, *this text is italicized.*

By that same token, you can also italicize the text by using html-style blocks (<>) for the same effect. As an example of this, <i>this text is italicized.</i>

How did I get around it just now? HTML character codes:

 &#42; = *
 &lt;  = <
 &gt;  = >

0 Replies

· Add your reply
  • Sort: 

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

137 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 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

float precision, wrong computations 1 Answer

Convert double to float for Vector3 1 Answer

Precision problem when moving Rect values 2 Answers

Vector3 using Doubles Instead of Floats 2 Answers

maximum distance from origin (float precision) 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