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 Alanimator · Dec 02, 2013 at 07:40 PM · collisionrigidbodymesh

What is the best method to use to ensure perfect collision detection on moving bodies?

I have a space game heare where my main character is a fast moving space ship.

I have many objects in my scene which my space ship should be able to crash into . I am using Occlusion culling on my camera so allowing the ship to even barely pass through any object is not an option.

My parent child relationship of my ship looks like this

▼ShipBody

Mesh

My ship currently passes through my objects even though i have placed a mesh collider on Mesh and a Rigidbody on ShipBody.

you can disregard what I have said but i would just like to know the best war to ensure continuous perfect collision detection.

Comment
Add comment · Show 6
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 GameVortex · Dec 02, 2013 at 07:48 PM 0
Share

First obvious question would be: Have you put a collider and Rigidbody on the objects you want to collide with as well?

Also to ensure better continuous collision detection you can go into the ships (and objects) rigidbody and change the "Collision Detection" property to "Continuous Dynamic".

Are you by the way moving your ship using force and velocity in rigidbody or translating it with transform?

avatar image Alanimator · Dec 02, 2013 at 07:55 PM 0
Share

yup I added rigidbodies to the objects to be collided with.

I have tried setting the collision detection to continuous dynamic but i get the same result.

I am moving the ship using Transform.

avatar image robertbu · Dec 02, 2013 at 07:55 PM 0
Share

Reducing the fixedTimestep seems to have the biggest impact on mitigating this problem: Edit > Project Settings > Time. Try reducing the fixedTimestep from 0.02 to 0.01 to start. The smaller the number, the better the detection, but at the cost of CPU cycles. You might also take a look at this script:

http://wiki.unity3d.com/index.php?title=DontGoThroughThings

avatar image GameVortex · Dec 02, 2013 at 07:59 PM 0
Share

When moving the ship using the transform you are in reality just teleporting it to a new position each frame. No physics calculations are done. You can try moving it with .ApplyForce or .$$anonymous$$ovePosition of rigidbody ins$$anonymous$$d. Or using the script that flaviusxvii provided belove.

avatar image Alanimator · Dec 02, 2013 at 08:10 PM 0
Share

well yeah in actuality i'm just moving the position of the ship over short intervals using Transform .If thats the cause , it is rather problematic . I will try the code flaviusxvii linked me to . if that still does not work I will revert to using ApplyForce.

Show more comments

1 Reply

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

Answer by flaviusxvii · Dec 02, 2013 at 07:53 PM

http://wiki.unity3d.com/index.php?title=DontGoThroughThings is helpful.

Comment
Add comment · Show 5 · 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 Alanimator · Dec 02, 2013 at 08:36 PM 0
Share

passes through like a hot knife through butter

avatar image flaviusxvii · Dec 02, 2013 at 10:32 PM 0
Share

I have a space combat game that uses a slightly modified version of the script to ensure that weapons fire doesn't skip past stuff. It works great.

You must not have colliders set up properly. Were you fiddling with layers at all?

avatar image Alanimator · Dec 03, 2013 at 08:33 PM 0
Share

it works now but i had to attach a collider ,Rigidbody and the script to ShipBody and now i am unable to hit $$anonymous$$esh with a projectile unless i remove the rigidbody from ShipBody .

is there a way to work around this and keep both functionalists ?

avatar image applejuices · Dec 03, 2013 at 08:40 PM 0
Share

I am not an expert, but I hear a lot that mesh colliders glitch a lot, I suggest putting one or many box colliders. Unity can prosses physics better with box colliders (Faster, more efficient, not to mention actualy collide)

avatar image Alanimator · Dec 03, 2013 at 09:55 PM 0
Share

that would be impossible with the current structure of my space ship . and also the codes i have require that i have just one 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

19 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

Related Questions

Unity 5: No collision with other objects after an animation? 0 Answers

How to allow collisions on a Child of a Non Kinematic RigidBody ? 1 Answer

Unreliable collision detection between rigidbody and mesh collider 1 Answer

Accessing the rigidbody of a linerenderer via Script 0 Answers

Checking collisions between two objects that don't have rigidbodies 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