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 Joshdbb · Jan 24, 2015 at 04:32 PM · 2dcollisionmecanimmissingcontinuous

Mecanim - Fast moving collider not colliding

I am trying to create a kind of simple 2D fighting game. I have a game object that represents a character which has a child object that represents the a melee weapon (currently a sword) that they are holding. The sword object has a Collider2D attached so that I can detect when the sword collides with another character/weapon.

I am trying to use mecanim to animate attacks but I have run into a problem; the sword often moves too fast and so passes straight through other colliders.

I attempted to add a rigidbody2D to the sword so that I could set 'Collision Detection' to 'Continuous' but this didn't solve the problem and also had some other negative side effects (the sword wouldn't always be in the correct position). I guess this makes sense as it is mecanim that is moving the sword rather than the physics engine.

I also attempted to add a separate child object which I moved the collider onto, I then tried to update the position of this new object to match the sword that is controlled by mecanim. This also had negative effects and the collider seemed to always lag behind the sword.

This feels like it should be a very common thing to need to do (animate a fast moving collider) for any kind of fighting game so I'm probably either missing something or going about this the wrong way entirely.

Any ideas how I could solve this problem?

Thanks

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
0

Answer by carrollh · Jan 24, 2015 at 05:42 PM

It really depends on what you're doing. Different colliders behave differently as they interact with other things. For instance, you might have noticed that in certain configurations your character will register collisions with walls, but not with moving enemies.

I know you can do the rigidbody thing with your weapons, as that's exactly what I do. But you have to update the local position and rotation of the weapon every frame because the rigidbody physics want to move it around. You don't need a rigidbody (you can use a regular collider instead) unless you want your weapon to push/bash other rigidbodies around.

Look here for a very good outline of when you should use the different things: http://answers.unity3d.com/questions/7671/guidelines-for-using-rigidbody-collider-characterc.html

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 Joshdbb · Jan 24, 2015 at 06:41 PM 0
Share

I seem to have finally got it to a point where none of the collisions are missed by having a separate collider object with a rigid body and continuous collision detection. I update its position and rotation every frame as you suggest, however the collider always seems to lag slightly behind the actual sword.

Where do you update your position?

avatar image carrollh · Jan 31, 2015 at 06:56 PM 0
Share

Sorry for the delay. I just do it in the Update method of the script attached to the weapon. Is that what you mean. How are you debugging? Are you debugging on a device on just in the editor?

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

20 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

Related Questions

Collision problem 0 Answers

2D box colliders not touching but are colliding, how to fix? 0 Answers

Weapon System with collide detection (Helps with script pls)!!! 0 Answers

Collision vs trigger 1 Answer

Modular Room System Similar to Mega Man 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