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 ShimanGleb · Oct 15, 2021 at 07:39 AM · triggercollision detection

Trigger events sometimes not working disregarding frame rate

Hello, everyone! I have a trigger attached to character hand to act as an attack box, and recently noticed the OnTriggerEnter sometimes not reacting to enemy colliders. Already tried most popular solutions: increased fixed timestamp (up to 0.001), added rigidbody (with Continuous Dynamic collision detection), and reduced animation speed - still no signs of improvement. Even tried to replace trigger with OverlapSphere, but result is the same, even when I did OverlapSphere check with "InvokeRepeating" with repeat rate 0.001s. Colliders are not small - 1 in radius and 10 in height for attack box and 2 and 8 for an enemy, so it's hard to believe that the issue's in size. Do I still miss something, or it's some common unity issue I did not hear about?

Comment
Add comment · Show 8
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 xxmariofer · Oct 15, 2021 at 09:13 AM 0
Share

how are you moving the colliders? physics get updated using fixedtimestep frequence. the invokerepeating and overlapsphere make no sense remove it

avatar image ShimanGleb xxmariofer · Oct 15, 2021 at 10:14 AM 0
Share

They're attached to skeleton bones: whether character performs attack, trigger moves along with the bone. The enemy collider is static.

avatar image xxmariofer ShimanGleb · Oct 15, 2021 at 10:25 AM 0
Share

use the physics debugger to see if the collider are moving correctly

Show more comments

2 Replies

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

Answer by tfalmeida91 · Oct 15, 2021 at 04:01 PM

Have you tried attatching a RigidBody with Continuous detection mode (Not continuous dynamic) to the objects that are supposed to be hit by the sword?

I have once fiddled with this issue and found out that I could put a bullet (or many) travelling at the speed of light (exagerating a bit but you get the ideia) and it still detected the collision, but setting the rigidbody on the bullet as Continuous Dynamic, and objects that slow or static, with Continuous. It worked flawlessly.

Edit: If the fast moving object is being moved by an Animator and not a Rigidbody, make sure you set the Update Mode of the Animator to "Animate Physics"

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 ShimanGleb · Oct 15, 2021 at 04:31 PM 1
Share

Good idea, but result was the same. Can't tell exactly if it became better (as this issue is very random) but I'm trying to completely get rid of it:)

avatar image tfalmeida91 ShimanGleb · Oct 15, 2021 at 04:33 PM 1
Share

Oh, another VERY important thing, if you want the collisions to happed, then the movement of the fast moving object AKA the sword, must intirely rely on the physics, for example, I moved my bullets with rigidbody.addforce

If it's an animator, try checking for AnimatePhysics

avatar image ShimanGleb tfalmeida91 · Oct 18, 2021 at 06:37 AM 1
Share

YES, this is it! At least I was not encountering this problem for 3 days straight. Thank you very much!

Show more comments
avatar image
0

Answer by SamElTerrible · Oct 15, 2021 at 01:12 PM

I had a similar issue in the past when adding a collider to a swinging sword to deal damage. I think collision detection in this case is not fully trustworthy; and trying to patch it didn't really help.

Instead, I'd suggest you send an event at a specific point (or several points) during your attack animation through code. If an enemy is within range when this event is sent, then they'll take damage.

This way you don't need colliders and will get more predictable results.

Comment
Add comment · Show 1 · 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 ShimanGleb · Oct 15, 2021 at 04:03 PM 0
Share

Thanks, that's an option, but I'd rather leave it as a last resort, because, first, it won't be cool for user experience to make hits at certain animation points, second, putting lots of animaiton event even for one animation would be a pain, and I have about ten more to fix. Maybe if I add this solution to current implementation it'd make up for missing hits, but I first want to find out if there's an easier solution:)

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

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

Can't get trigger collision detection to work 1 Answer

Colliding with multiple objects 1 Answer

Neither collision nor trigger being detected 3 Answers

Draw line within bounds of circular collider 0 Answers

Does OnTriggerStay don't detect a collision with a non-trigger collider? 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