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 rah · Feb 18, 2013 at 04:16 PM · physicscapsulecastcapsulecastall

CapsuleCastAll fails after 20 calls

I'm using Physics.CapsuleCastAll for my game's melee attack system. After 20 calls, it starts returning 0 collisions every single time. I can even put in a loop like this to speed testing:

     for (int i = 0 ; i < 21; ++i)
     {
         RaycastHit[] results = AED.Cast(_args.Activator);
         Debug.Log("Hit " + results.Length + " objects");
         foreach (RaycastHit target in results)
         {
             if (target.collider.gameObject == _args.Activator.gameObject) continue;
             
             _args.Activator.NotifyMadeAttack(target.collider.gameObject);
         }
     }


In this loop, the Debug.Log value will get 20 valid hits in a row, followed by a single "Hit 0 objects" result. If I attack again, all 21 attempts will come back with 0 hits. I've also done this manually, i.e. not looping my hit-check code, and it still starts failing on the 21st call. Is there a pool I have to clear or something?

Comment
Add comment · Show 2
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 Loius · Feb 18, 2013 at 04:39 PM 0
Share

I'd guess that Notify$$anonymous$$adeAttack does damage and kills the object's ability to register as a hit object after some point.

avatar image rah · Feb 18, 2013 at 04:43 PM 0
Share

Notify$$anonymous$$adeAttack doesn't kill or remove any objects. It just notifies the attacker that the hit landed, and at present it's an empty stub. I'll also add that collisions fail for EVERYTHING in the world after the 20th call, not just the one thing I was hitting. The same thing happens if I hit one object 10 times and then another object 10 times...all casts after that return nothing.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rah · Feb 18, 2013 at 11:09 PM

Found the issue - float error was accumulating in the Z value until the collision test was beside my tiles (this is a sideview, orthographic project).

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 JoeStrout · Jan 06, 2014 at 07:47 PM 0
Share

In the Z value of what? I don't see anything that your test code is reusing. I'd love to understand this problem better before I run into it in my own game, so if you could elaborate, that'd be great!

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

11 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

Related Questions

Test stationary capsule against colliders in scene. 2 Answers

How to use the new Physics2D.OverlapCapsule & CapsuleCast 0 Answers

Ways to work around OnCollisionStay/Enter events firing one frame late? 2 Answers

Is the CapsuleCast function broken? 1 Answer

CapsuleCastNonAlloc not filling results buffer in 2018.2 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