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 LeftyTwoGuns · Sep 21, 2014 at 11:12 PM · raycastcollidermecanimanimator controller

How do you accurately sync the position of colliders on an animated character in the physics engine?

I've been trying to figure this problem out for a week now and haven't found any solutions.

I have a NPC with colliders attached to different bones using Unity ragdoll wizard. They're supposed to be targets for a Physics.raycast projectile. Except, the raycast will go through some colliders depending on the animation the NPC is performing. The NPC is using a Mecanim Animator Controller.

From my research, the problem appears to be that despite the colliders appearing that they're moving with the animation in the game window, they're not really synced in the physics engine.

I've tried everything I can think of to fix this. I tried changing the fixed timestep, tried all sorts of sizes and shapes for the colliders, the colliders all have rigidbodies set to kinematic, the Animator Controller has Animate Physics checked, etc. The closest I have gotten to accurate raycast hits is changing the colliders rigidbody to interpolate but this obviously completely messes up the animations and can cause tons of deformations.

Does anyone have any thing to share or any experience dealing with this? I've seen multiple topics and questions dealing with the exact same issue but no responses. The only thing I can conclude now is that it's not possible in Unity to accurately fire raycasts at colliders attached to a Mecanim character.

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
1
Best Answer

Answer by gilley033 · May 27, 2015 at 07:26 PM

I believe the issue is that Animation changes are only applied after the Update phase (full Execution Order can be found here), thus if you are performing the raycast in FixedUpdate or Update, technically the raycast is being performed on the animation state from the previous frame (since the current frames animation change hasn't occurred yet).

To correct this, put your raycast or other physics code in LateUpdate. This will allow you to still destroy objects based upon the results of your raycast, since the Scene Rendering phase only occurs after Late Update.

Hope this helps!

Comment
Add comment · Show 2 · 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 LeftyTwoGuns · May 27, 2015 at 08:24 PM 0
Share

This is exactly what I wound up figuring out a while ago. Stumped me forever lol. But thank you for your very helpful reply!

avatar image gilley033 · May 28, 2015 at 06:54 PM 0
Share

No problem, hopefully others can find some use from this info!

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

25 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

Related Questions

Raycast occasionally won't hit colliders on Mecanim animated characters (but hits perfectly if Animator is disabled) 1 Answer

What is the difference between Animator Controller and Animation component? 1 Answer

Do animations affect the accuracy of a collider? 0 Answers

Raycast wont hit colliders on mecanim 0 Answers

ball sometimes goes through the bat when hit... collider problem... How to do a Raycast? 0 Answers


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