Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Accuracy in Combat: Precision Game Design. Mesh Collider (v) Capsule Collider inaccuracy problem.

Discussion in 'Physics' started by Deleted User, Jun 10, 2018.

  1. Deleted User

    Deleted User

    Guest

    Hi Forumers,

    With respect to the Unity team, the sphere and capsule colliders work well with block objects (spaceships, tanks, airoplanes etc..) they are problematic in other areas.

    Collision detection using humanoids is the subject. It is clear that sphere and capsule colliders will not quite do. As a basic for testing yes but definately not final game.

    Please see the example below. A 3D Model of the exact problem mentioned in this thread.

    https://postimg.cc/image/84qw2lkmv/

    If you get "hit" and on screen its not really a hit but a "miss" this pisses the player off. They are inclined not to like your game.

    Is there a CPU Monitor in Unity for mesh collision detection. A frame-rate counter is essential.
    Also, is it clear from a Game Design point of view that in Unity, humanoids were not made for capsule/sphere colliders?*

    * Discounting 3D isometric / army / zoomed out camera games whereby turn based combat does not rely on limb accuracy. Think Age of Empires. Sphere and Capsule Colliders would work on that. Not so for 3d Streetfighter games.

    ** PS the game is a sf2 variant. it will only ever have 2 giant humanoids, perhaps 3 maximum, on screen at once.
     
  2. Deleted User

    Deleted User

    Guest

    The question in the link is "Can sphere colliders change shape during movement to reflect animation of character."
     
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Look into polygon collider, or create a system that will allow individual colliders on each limb/bone.
     
    Deleted User likes this.
  4. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    75
    Use ragdolls for your characters, and check for hit / damage in each collider
     
    theANMATOR2b and Deleted User like this.
  5. Deleted User

    Deleted User

    Guest

    Thank you. I’m super busy but will return to this methodology. Is it true to say that mesh collider is the most accurate method out of all of them?
     
  6. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    75
    Yes, but mesh colliders can be expensive depending the way they are being used.

    With a ragdoll you can achieve what you want with simpler colliders, for example:
     
    Last edited: Jun 15, 2018
    theANMATOR2b and Socrates like this.
  7. Deleted User

    Deleted User

    Guest

    Hi Weendie,

    That looks pretty cool, and usable besides the giant capsule covering the actual robot. Of course it may be important to your game mechanic, which is understandable. I like the individual limb capsules.
     
    Weendie-Games likes this.
  8. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    75
  9. Deleted User

    Deleted User

    Guest

    Hi Weendie,

    Interesting link.

    Can you use these with mo-cap?

    Cheers.
     
  10. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    75
    Yes, with regular and mocap based animations, also you can use with inverse kinematics.
     
    Deleted User likes this.
  11. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    788
    One other thing to note is that colliders aren't really suited for projectiles or any fast moving objects.
    I've even found that melee attacks can "miss" if the animation is too fast.
    I found implementing a system of raycasting from the previous location to the current location and checking for hits is much more reliable.
    I'm not sure if you're facing that problem, but thought it might help someone ;)
     
    Weendie-Games likes this.
  12. Deleted User

    Deleted User

    Guest

    Ive bookmarked this thread Serinx so that all the possibilities are looked into, but I will say that the game is aimed at high end hardware only. PlayStation 4 Pro , Xbox One and a good meaty PC. Which should in theory mean that mesh colliders will be the solution. That kind of hardware has more than enough computing power to check mesh characters.

    The aspect of animation going too fast and melee attacks is worrying. Combat is all in this game. Nothing is worse to a user than seeming hitting the opponent and nothing happening.

    I am guessing that the hardware you are using may not be able to cope with the code refresh check by frame? (ie it is trying to do too much things at once). If it runs at 25fps then that should be enough for any animation check to register a hit. That's far too fast for the human eye (checking the frame 25 times in 1 second). Why cannot it check a collision in those 1/25ths of a second?

    More likely it could be the code, have you initiated everything in the right order? Removed libraries you don't need in the scene? Initialised the colliders first? then draw objects. There are many things.

    If none of these work then I am certain that collider code does not check and refresh each frame that would register the "hit". It will only take its last known position in code, based on the X,Y,Z position in the inspector box of the collider. If the animation has moved, it is not updating the colliders movement quick enough.

    Its a little worrying because we also will use projectiles with particle effects. Theres nothing worse than playing all of that when the projectile hits "empty air."

    Finally, Raycasting is not cheap on CPU power is it? If you go low end PCs or mobile your up sh*t creek.

    Heres a paddle :)
     
  13. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    788
    @RamZada It is not to do with the framerate, but the physics update rate. You could increase the accuracy since you're aiming at high end systems and you may avoid this problem alltogether.

    This video demonstrates the solution I was talking about:

     
    Weendie-Games likes this.
  14. Deleted User

    Deleted User

    Guest

    Reminds me of Nosferatu on PC, another great game. It might even be the same engine. Your game looks cool, unfortunately there is nothing to show our end, we just started last month. Expect a years dev. We are more StreetFighter than massive RPG.

    1m17sec is simply brill :p