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
2
Question by Internetman · Apr 20, 2016 at 12:21 PM · c#collisioncolliderenemyspeed

Object moving too fast, so that the collider does not work (C#)

Hi! I just found out a problem with my game, I've created an enemy that "fly's by" the screen in order to hurt the player, but the problem is that the enemy moves to fast so that the collider doesn't interact.

How can I fix this so that the enemy will take damage to the player no matter how fast it is going? Or well how fast it is currently going?

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

2 Replies

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

Answer by Dave-Carlile · Apr 20, 2016 at 12:27 PM

You can set the collision detection mode to one of the Continuous values. One thing to note from the documentation:

This has a big impact on physics performance,

The physics engine must do a lot more math for this so use it judiciously.

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 meat5000 ♦ · Apr 20, 2016 at 01:08 PM 0
Share

I did some tests on this a while back. The descriptions of the Collision modes are a little deceptive and dont actually help much with the speed problem beyond a certain amount.

The docs talk about which modes to use in which situations but in actual fact they are designated for particular scenarios and arent really meant for improving detection for fast movers, much.

The testing I performed drew the conclusion that the only way to detect collisions beyond a certain speed was to use a $$anonymous$$esh Collider as it was the only Collider capable of keeping up. The difference was huge.

http://answers.unity3d.com/questions/900306/rigid-body-continuous-and-continuousdynamic-seem-t.html

avatar image meat5000 ♦ meat5000 ♦ · Apr 20, 2016 at 01:08 PM 0
Share

Seems like a lot of the comments have been deleted in that thread! Sorry.

avatar image Cherno meat5000 ♦ · Apr 20, 2016 at 09:37 PM 0
Share

I'd suggest to forget about the collision modes, you'll never make them 100% reliable for fast-moving objects. Ins$$anonymous$$d, raycast from the last frame's position towards the current position. This will ensure that all colliders between both positions will be caught. You could also use Physics.SphereCast etc.

There sould be a sample script implementing this method somewhere on the net, possibly on the Unity user wiki.

Show more comments
avatar image
1

Answer by gamedevelopmenttsunami · Apr 30, 2019 at 02:33 PM

What @cherno says is probably the best solution. There was a deep discussion a few years ago about how discrete and continuous detection have almost no difference in accuracy, when detecting fast moving objects. So don't bother.


I'd suggest to forget about the collision modes, you'll never make them 100% reliable for fast-moving objects. Instead, raycast from the last frame's position towards the current position. This will ensure that all colliders between both positions will be caught. You could also use Physics.SphereCast etc. There sould be a sample script implementing this method somewhere on the net, possibly on the Unity user wiki.


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

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

141 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 avatar image avatar image avatar image avatar image

Related Questions

Fist Punch Collision 0 Answers

Collider collision processing speed 2 Answers

Can an object to transfer to another as it increases your speed? 1 Answer

Picked up objects passes through objects 2 Answers

Why does the player jump is not so high if he touch 2 objects at the same time as if it touch only 1 object? 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