Search Unity

[RELEASED]Physical Bone - Make your bone system colourfully

Discussion in 'Assets and Asset Store' started by HSUPA_TheNext, Feb 18, 2016.

  1. HSUPA_TheNext

    HSUPA_TheNext

    Joined:
    Feb 18, 2016
    Posts:
    4
    Physical Bone is a asset that can use bone systems to simulate soft body physics.
    It can simulate hair, ragdolls, cloth, rope or other soft bodies.

    It supports colliders and wind zones to receive wind forces and interact with collisions(Supports sphere collider, box collider, capsule collider and terrain colliders)
    Physical Bone is easy to set up with basic functionality and can generate much more diversified results with some more involvement




    Version info
    v1.0 First release
    New in v1.01
    - Fixed bug that cause error when use AddComponent<PhysicalBoneManager> and AddComponent<PhysicalBone> in script at runtime.
    - Add functions to setup bones dynamically.
    - Add demo 'DemoDynamicalSetup' for guide to setup bones dynamically.


    Physical Bone on Store

    WebDemo
    Demo01
    Demo02
    Demo03


    If you have some questions or suggests or found some bugs, please send E-mail to contact@TheNextGames.com, and you can also post a reply here.
    We will get to It as soon as possible.










     
    Last edited: Mar 2, 2016
    ikazrima likes this.
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    This is a really nice looking tool.
    I'm interested, is there any documentation for the package available to review before purchasing?
    Can you define the limitations of this tool and what's on the roadmap for future iterations?
     
  3. HSUPA_TheNext

    HSUPA_TheNext

    Joined:
    Feb 18, 2016
    Posts:
    4
    Hi theANMATOR2b
    If you need a documentation before purchasing, please E-mail us and we will send that to you.
    One thing to note is this asset can not simulate planer objects perfect like cloth, you must to make some limit to the bone(please consult the skirt in Demo01).But we have a schedule to develop a special cloth simulation for bone system.
    All in all, we will make performance of this tool more realistically, and can simulate more type of soft body.
     
    theANMATOR2b likes this.
  4. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    977
    It's problematic to add physical bones at runtime. Just doing AddComponent<PhysicalBone>() will cause several errors. You need to manually go in and fill arrays. It would be neat if that was handled automatically.

    Also, foreach-loops are used by this asset at runtime, which is bad. Foreach-loops cause garbage, so for-loops should be used instead.

    It would be a good idea to namespace this too, so the global namespace isn't cluttered.

    Other than that, great asset.
     
    theANMATOR2b likes this.
  5. HSUPA_TheNext

    HSUPA_TheNext

    Joined:
    Feb 18, 2016
    Posts:
    4
    Hi SunnySunshine
    Thanks very much for your suggestions.
    We will solve that as soon as possible.
     
  6. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    977
  7. sirio21

    sirio21

    Joined:
    Mar 11, 2013
    Posts:
    114
    hi! Can i attach in a easy way the bear to the end of rope?
     
  8. HSUPA_TheNext

    HSUPA_TheNext

    Joined:
    Feb 18, 2016
    Posts:
    4
    Hi sirio21
    You can just attach the bear to the end of rope by a new script at present, I'm sorry for this.
    But we will add this function as a option that could attach any object to a bone in a later version.

    Here is the simple script code for reference.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Attach : MonoBehaviour {
    5.  
    6.     public Transform endofRope;
    7.     public Transform bear;
    8.     public Vector3 offset;
    9.  
    10.     void LateUpdate () {
    11.         bear.position = endofRope.position + offset;
    12.     }
    13. }
    14.  
     
  9. Nyo_

    Nyo_

    Joined:
    Mar 16, 2016
    Posts:
    1
    Looks like it couldnt control the softness?;)
    Just want something like damping, elasticity and stiffness to control the softness
    I'm glad to have it if this component has been finished:)
     
    Last edited: Mar 16, 2016
  10. kumagames

    kumagames

    Joined:
    Apr 18, 2014
    Posts:
    3
  11. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,490
    Hi, does your asset work with physics forces?
     
  12. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    This asset is good but it is not performant for high number of bones / colliders. The author set up a limit of max 500 bones, but that can be changed easily if you're a coder.

    But saying that, having only 50-100 bones & colliders already eats up FPS a LOT.
    For 20-30 bones it still performs ok, I still to manage to hit 100 fps. Adding another 20-30 bones drop it to 50 fps. Close to a hundred bones and the my games chugs along 10-15 fps.

    Hopefully the author can optimize it in the future. I implemented my own fix and managed to gain about 40 fps more, now I can have 50++ bones & colliders at 80-90 fps.
     
  13. ikazrima

    ikazrima

    Joined:
    Feb 11, 2014
    Posts:
    320
    Someone asked how I made the performance gains from my previous post, so I'll share it here for others.
    Hope this helps.

    In PhysicalBoneManager.cs

    There's a
    GetComponent<WindZone>
    in the update loop. Move to it to start. It's not necessary to get component every frame.

    The biggest performance gain can be made here.

    In PhysicalBone.cs, PhysicalBoneBase.cs & PhysicalBoneCollider.cs.

    Replace every
    == null
    check with:

    bool isNull = ReferenceEquals(someVariable, null);

    In PhysicalBone.cs, PhysicalBoneBase.cs & PhysicalBoneCollider.cs.

    The most tedious, but you can also gain quite a number of fps here.
    For every addition, multiplication etc2

    Instead of
    vectorA + vectorB
    do

    Code (CSharp):
    1. vectorA.x += vectorB.x;
    2. vectorA.y += vectorB.y;
    3. vectorA.z += vectorB.z;

    This changes the usage workflow, so thinks if it's really necessary.

    PhysicalBoneCollider.cs loops through all the colliders, at all times. So you're wasting CPU time here on bones that doesn't even collide.

    I made every child in Bone Attributes have its own collider. Use sphere collider because it's what PhysicalBoneCollider uses.

    I also made PhysicalBoneCollider have Unity colliders + kinematic rigidbody + no gravity.

    Do a collision check in OnTriggerStay & OnTriggerExit for the custom unity collider.

    In the for loops, I made sure that the PhysicalBoneCollider only checks if any custom bone collider is colliding with it based on layer specified.

    Now you can have hundreds of colliders with no performance loss.

    PhysicalBone.cs uses custom inspector for BoneAttributes. It's not performant as in every redraw if does a whole lot of loops & variable referencing that is very resource heavy. (I think it uses .Net reflection? Might be wrong.)

    I moved BoneAttributes into a custom class and just uses the default drawing behavior for the inspector.

    Now your editor won't freeze every time. You can also do multiple component edits like this, very useful if you have hundreds of bones and you need to freeze certain child.

    Referencing x4000 review on the asset store:
    Implementing my fixes above, I can manage to just use a single PhysicalBoneManager.
    In Start, do a find components for PhysicalBone & global PhysicalBoneCollider.
    Voila, all bones share the same colliders with no performance loss.
     
    Last edited: Jan 25, 2019
    SunnySunshine likes this.
  14. BlastingGamesSL

    BlastingGamesSL

    Joined:
    Jul 24, 2017
    Posts:
    8
    Hi! I have a problem with this asset. After finding a configuration that looks good for my character, it only works well when facing its initial direction. When I press Play I can see it working well and I can run and jump and whatever and the hair looks awesome, but when I turn to a different direction (specially when facing back) the hair becomes totally deformed until I turn again to face the initial direction of the character. If I rotate the character in the editor before pressing Play it works well, so the initial direction works in any direction, but allways gets messed up when turning arund. If that helps, for some reason even the bone axis direction of my model joints and the ones in the demo character are the same, I need to set the Bone Axis in the Physical Bone script to X Reverse instead of Y in order for it to work with my model (but with the problem said above).
    Any ideas?
    Thanks in advance!
     
  15. Gavert

    Gavert

    Joined:
    Jan 31, 2017
    Posts:
    12
    Is it possible to suspend a rope on two ends with this asset?