Search Unity

Bone Controller [RELEASED]

Discussion in 'Assets and Asset Store' started by Tryz, Feb 16, 2015.

  1. macodys

    macodys

    Joined:
    Jul 22, 2012
    Posts:
    64
    Hey,

    I bought the bone controller couple a days a go and i was wandering if you can make the hands of the player touch the wall if the player collides with the wall. Like mirror's edge here is a screenshot:

     
    mkgm likes this.
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @macodys

    There's a couple of ways to do this. In each, there's are three things to think about:
    1. You're getting the arm (shoulder to wrist) to reach out to the wall
    2. You're bending the wrist so the hand-bone runs parallel to the wall
    3. You're opening up the fingers so the hand is spread wide

    Off the top of my head, there's two ways you could do this:

    1. Just using existing motors
    To use the existing motors, I'd use a "Limb Reach" motor that would get the arm to reach out to the wall. You'd just have to find some point on the wall that you want to use as the target and set that in the motor. This is very similar to the Limb Reach Motor Demo in the package.

    Then, use a "Pose" motor that simply bends the wrist (hand-bone) so it's perpendicular to the fore-arm and parallel to the wall.

    Finally, use a "Finger Pose" motor to uncurl the fingers.

    By setting the target (on the Limb Reach motor) and activating the three motors, you'd get what you want.

    2. Create a new motor
    Using the Bone Motor Builder's Guide, you could build a single motor that does all the things I mentioned above. In this case, you're really just copying the code out of the motors I mentioned above and putting them into a more compact motor.


    In both cases, really the only new thing you have to do is determine if there's a wall near by and determine where you want the target point to be for the Limb Reach motor.

    I'm happy to help if you get stuck. Feel free to shoot an email to tim@ootii.com.

    If you're not sure about doing it yourself, I could put together an example. However, I'm packed right now and it will probably take me about two weeks to get to it.
     
    macodys likes this.
  3. macodys

    macodys

    Joined:
    Jul 22, 2012
    Posts:
    64
    Thanks! That worked. I put a trigger to the wall, i attached a sphere into the camera and i set it when the sphere enters the trigeer to enable the bonecontroller script. Right now i used only the limb reach motor and it works very good. I tried to add a pose motor too but for some reason it doesn't let me add a bone when i press the + sign. Is this a bug?
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Awesome! Good job. :D

    It should. Make sure you have the Unity "hand" selector selected. Then, select the bone you want to add. Lastly, press the + sign. That should do it.
     
  5. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,962
    How easy would it be to use Bone Controller to imitate a marionette? Not a real one controlled by sticks, but something like the mecanim dude, responding to WASD, but maybe moving using a mix of animations and forces.

    I was thinking about the staggering drunk type mechanic used in a few games, and wondering if BC would lend itself toward that, then started wondering if it was feasible to do some form of marionette.

    Just curious. :)
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Definitely doable.

    I think the tricky part is really the same as a rag-doll. Having gravity effect all the bones separately and collision responses that are realistic (ie your foot doesn't end up at the back of your head) is really the tough part.

    Once that's worked out, having controls that pull body parts (whether it mimics a string or some internal force) would actually be pretty easy. I pretty much have that with the "Limb Reach Motor" as the limbs try to reach out to the target position.

    My brain goes crazy with all the things I could be doing with BC and other assets (and Unity in general). :eek:
     
  7. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,962
    +1 for crazy brains, and the prospect of maybe having a new feature to roll out on BC every six months. ;)
     
    Tryz likes this.
  8. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    69
    Hello,

    Would there be an easy way with this system to make a character hold a sword or a gun or some kind of weapon? I imagine this is a common problem faced by developers and I wonder if there is any easy solution?
     
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    That would be Mount Points:
    https://www.assetstore.unity3d.com/en/#!/content/16318

    You can also use Unity's normal hierarchy to do this, but I found drilling down to find the desired bones was a bit of a pain. Then you have to deal with orientation. Mount Points was my solution for that.

    So, you'd use Mount Points (or manual placement) to attach the sword and then the Finger Pose motor to make the hand look like it's grasping it.
     
    Last edited: Jul 22, 2015
    DMeville likes this.
  10. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    69
    Nice, thanks for the info.
     
  11. Barachiel

    Barachiel

    Joined:
    Nov 25, 2012
    Posts:
    147
    Definitely picking this up, looks quite useful for a variety of things. =)
    Just as a heads up, I think you forget to add the Asset Store link to your first post. With the title of this thread announcing that it's released, that's probably a good idea. =P
     
    Tryz and hopeful like this.
  12. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    You rock! Thank you.

    It's fixed. :)
     
  13. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    @Tryz I have another question for you! I'm still unfamiliar with the asset a bit.

    I have a character I've rigged myself and I want to animate it with some free animations I've found. The problem is the animations have ONE bone in the wrist, where my character has two.

    The reason my character has two bones is to prevent ugly twisting on the wrist.
    Screen Shot 2015-07-28 at 11.30.43 PM.png

    As you can see with two bones distributing the y-rotation results in much cleaner looking deformations.
    Screen Shot 2015-07-28 at 11.38.16 PM.png

    So my options here are:
    1. Go into all my animation files, apply the animation to my own rig (with the extra bones) and manually adjust the wrists.
    2. Do something less time consuming procedurally.

    With Bone Controller, is there a way for me to intercept the bone rotations and distribute the wrist rotation through a joint chain? Is this something suitable for Bone Controller?

    Thanks again!
     
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Yes!

    The Pose Motor bone is a great place to start because it's close to what you're looking for. If you play the demo, you'll see that this motor example plays an idle animation and then it overrides each bone animation with a preset pose (depending on the weight you choose).

    The Pose Motor code (PoseMotor.cs) looks a bit long, but most of that is editor support. What you really want is inside the Update() function loop (about 30 lines). Look at lines 86 to 114 and line 123.

    You won't care about all the preset pose lerping. What you really want is the "current rotation" and then simply split that and set it on your two bones.

    If you get stuck or just need some advice, shoot me an email at tim@ootii.com. I'm happy to help.

    PS. You'll need to know when you want the motor to run (meaning when the animation plays) or it will do the work all the time. Other than that, it shouldn't be too tough.
     
    DMeville likes this.
  15. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    @Tryz Cool thanks! I haven't had a chance to try it out yet as I'm just starting to play around with BC yesterday and today. Starting with some simple feet IK and hand's closing to hold weapons.

    I have a quick question regarding the Finger Pose Motor; I've added the motor to the hands, and closed the right hand and it works great, except for one small thing. I assumed that since there is no overriding on the left hand fingers going on it would continue to play the underlying animation - but this isn't the case! The left hand with a value of 0 on each finger is just a rigid open hand. Can I control the weight of the finger pose motor on a per hand basis as it is, or do I need to dig into the code?

    I see that there is a "Weight" property on the Finger Pose Motor, but scrubbing that from 0 to 1 doesn't seem to have any visible effect.

    Thanks!

    Edit: I noticed the underlying finger animation works fine at startup, it's just setting it to anything then back to 0 forces the rigid open hand. Hmm

    EDIT2: Here's a gif showing what I'm doing - http://i.imgur.com/b82Q2Jy.webm
     
    Last edited: Aug 3, 2015
  16. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    I'll take a look.

    Give me a day or two. If it doesn't work, I'll get it fixed. ;)
     
    DMeville likes this.
  17. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @DMeville ,

    Looks like I wasn't applying the weight as I should. I've got it fixed.

    If you want to shoot your email to tim@ootii.com, I'll send you the new version. Assuming all is good, I'll put out an update to the Bone Controller.

    Thanks for being patient! ;)
     
    hopeful and DMeville like this.
  18. mkgm

    mkgm

    Joined:
    Apr 10, 2015
    Posts:
    134
    @Tryz, Hi...

    I would like to know if your asset works with "Ragdoll Workshop".

    In their forum, the developer says:
    I'm not familiar with Bone Controller, but it depends on how the package author has implemented all of the procedural motion. Basically, they need a way to compute the results of the motion on-demand, as opposed to simply applying it in LateUpdate() (which is the common approach). You'd then have to make a script that works like my RagdollAnimatorFinalIKSync component and just subscribe to the right events (this page may help).

    If your asset could work "out of the box" with Ragdoll Workshop would be awesome!!!

    Thanks.
     
  19. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Short answer: If you manage enabling/disabling the BC motors, they should work together.

    All of BC's work is done in LateUpdate(). I actually batch all the bone change requests (made through motors) and then apply them at the end of the update.

    You can disable all the BC motors and then any other package (like Ragdoll Workshop) can take over. Assuming Ragdoll Workshop "turns on" and "turns off", you can just make sure only one asset is active at a time. When you're ready for BC to start working again, you'd just re-enable the motors that should run.

    I hope that helps.
     
  20. DustySkunk

    DustySkunk

    Joined:
    Sep 12, 2013
    Posts:
    13
    Hi Tryz,

    I went to buy Bone Controller today but I have noticed that it isn't featured on your homepage (http://www.ootii.com/UnityAssets.cshtml) and the Asset store throws a warning that there might be compatibility issues with Unity 5 when you go to add it to the cart.

    It clear that you are still supporting this asset from this thread but are you planning on phasing it out or stopping further development? That wouldn't necessarily be a deal breaker for me but I'd like to know what I'm getting into so that I can make an informed decision.
     
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @DustySkunk ,

    I totally understand. The Bone Controller is an active product. I got a bit caught up in v2 of some of my other products, so I've left it in beta longer than I planned. But, it is active and supported.

    It's now on my Unity Assets page. That was just a total miss on my part. :eek:

    As for the comparability warnings, that's really odd. Just as a test, I created a new project and imported the latest version from the Asset Store. Nothing came up with that warning.

    There is a new warning when the asset loads. A message about the dynamic material I create for debugging may be removed in the future. I'll clean that up, but everything worked fine.

    I use it in my own Unity 5.1 projects without issues and I'm always here to help. :D
     
    DustySkunk likes this.
  22. mkgm

    mkgm

    Joined:
    Apr 10, 2015
    Posts:
    134
    Confirmed that works on Unity 5 :)
     
    Tryz and DustySkunk like this.
  23. DustySkunk

    DustySkunk

    Joined:
    Sep 12, 2013
    Posts:
    13
    Thanks for the quick response, @Tryz. My mind is at ease :)

    I just tried adding Bone Controller both through the browser version of the asset store and in the in-editor window with the same result~ I have uploaded the warning I receive below. It won't stop me from making the purchase but I thought you should be aware in case you want to investigate further
     

    Attached Files:

    Tryz likes this.
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Thanks! I'll see about uploading a version using Unity 5 and seeing if that helps get rid of it.
     
  25. mkgm

    mkgm

    Joined:
    Apr 10, 2015
    Posts:
    134
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @mkgm ,

    I took a look at the suggestion. Making sure "the final pose can be sampled during the FixedUpdate() loop" would be a challenge since Unity's animations typically process after FixedUpdate() runs. Since BC blends with animations, using FixedUpdate() would mean we're blending with old animation data that was already rendered. That's one of the reasons a lot of IK packages run in LateUpdate().

    Unfortunately, my focus is on MC v2 and BC integration... then additional motions and motors (not to mention my own game). I just can't commit to figuring out RW and making changes to support it. That isn't to say it won't happen... I just don't want to set any expectations.

    Yeah, I hate having to pick and choose. Meaning... I want to help and do it all, but there are just so many different assets to integrate with, so many ideas, and not enough time (or money) to do it all. :(
     
    Last edited: Aug 27, 2015
    twobob and DMeville like this.
  27. mkgm

    mkgm

    Joined:
    Apr 10, 2015
    Posts:
    134
    Tryz..

    I understand you 100%. Don't worry.
    By the way, thanks for the feedback.

    Good luck with your game!
     
    Tryz likes this.
  28. GrimDjim

    GrimDjim

    Joined:
    Jan 29, 2015
    Posts:
    7
    Hi Tim, I'm looking at buying this to help with my project. I just wanted to confirm it will be able to do what I need it to, which is to have my character reach down at a ragdoll, grab it by the ankle or wrist and drag it, something like in the Hitman games. Also to be able to pick up dismembered limbs (yes, I'm a bit weird). Is this do-able? Many thanks.
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @Azabryel ,

    Hahaha... I love game development. So much more exciting than e-commerce.

    For both, the simple answer is 'yes', but...

    In both cases, you can leverage the "Limb Reach Motor" to target an object and have your character's arm reach out to the exact spot you specify. That part will work out of the box. However, the "Limb Reach Motor" won't cause your character to bend at the waste or squat down. I'm guessing that would help the realism.

    For that, you've got two options:

    1. Use an animation that has your character bend or squat and then enable the Limb Reach Motor to reach out to the target. This probably makes the most sense as the "walk-and-drag" is probably a custom walking animation you have.

    2. You could create your own motor or customize the Limb Reach Motor so that it would include bending down at the waist. The BC was built for people to add and customize motors. So, it will require some coding, but I think it wouldn't be too tough. I'd be happy to help guide you if you take this route.

    I hope this makes sense. :)
     
    GrimDjim likes this.
  30. martinamenegon

    martinamenegon

    Joined:
    Aug 28, 2014
    Posts:
    28
    Hello, I have a question: i need to have ragdoll driven characters (1 prefab cloned tot times), that should fall on the ground.. their heads should follow a target (while being in ragdoll state).. is that possible with your asset?
     
  31. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Unfortunately, I don't do ragdoll physics at the moment. The BC could do it with a new motor, but I haven't created that motor yet.

    If you have another asset doing all the ragdoll calculations, there is a "Look At" motor that would allow you to control the head and do this.


    The BC was built to be expanded... it uses "bone motors" to make bones do different things at run-time. There's a prebuilt set of motors you can mix-and-match. However, you can also create your own motors. ragdolls are something I would eventually like to have as a prebuilt motor, but someone else could create it as well.
     
    Last edited: Nov 27, 2015
    martinamenegon likes this.
  32. martinamenegon

    martinamenegon

    Joined:
    Aug 28, 2014
    Posts:
    28
    thanks a lot for the reply :)
     
  33. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Last edited: Dec 6, 2015
    ZJP likes this.
  35. Alardaen

    Alardaen

    Joined:
    Aug 29, 2010
    Posts:
    85
    Hi Tryz is the BC and MCv2 already integrated? I mean, I just bought the MC v2 and since I want also the foot placement functionally is it safe to buy the BC to use it with Motion Controller v2?
     
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    The do work together, but they aren't automatically integrated. What I mean is that the MC code doesn't reference the BC and enable/disable bone motors in the motions themselves.

    The problem is that I can't reference the BC stuff in the MC because there's a lot of people that don't own the BC and the MC would generate errors.

    That said, the bone motors will work and the code integration I mentioned isn't really necessary. You would apply the BC per the documentation.

    So, the foot placement motors would simply be turned on (regardless of the MC). When I built the BC, I made sure I could handle things like jumping without having to enable/disable that specific bone motor.

    I hope all that makes sense. In the next week or two, I will have a video up that shows this.
     
    hopeful likes this.
  37. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    Hey Tim,

    I just downloaded the latest version of Bone Controller (Dec 5th update) and I'm having this exact same issue again.. :( perhaps the fix slipped through the update. I'm gunna revert for the time being, but I'd like to stay up to date! :)

     
  38. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Awe crap! I'm hoping I didn't overwrite the changes. I'll look into this.

    Sorry about that. :(
     
  39. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    No problem. Thanks for the fix :)
     
  40. Alardaen

    Alardaen

    Joined:
    Aug 29, 2010
    Posts:
    85
    Hello Tryz, in Unity 5.3 I´m getting this exception, when removing the prefab from hierarchy view and also when stopping the game play.

    MissingReferenceException: The object of type 'BoneController' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    com.ootii.Actors.BoneControllers.FootGround2BoneMotor.Update (Single rDeltaTime, Boolean rUpdate) (at Assets/ootii/BoneController/Code/Actors/BoneControllers/Motors/FootGround2BoneMotor.cs:292)
    com.ootii.Actors.BoneControllers.BoneControllerMotor.UpdateMotor () (at Assets/ootii/BoneController/Code/Actors/BoneControllers/BoneControllerMotor.cs:291)
    com.ootii.Actors.BoneControllers.BoneController.LateUpdate () (at Assets/ootii/BoneController/Code/Actors/BoneControllers/BoneController.cs:695)
    BoneControllerEditor.OnDisable () (at Assets/ootii/BoneController/Code/Actors/BoneControllers/Editor/BoneControllerEditor.cs:204)

    Version 0.21
     
  41. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,962
    BTW, I'm thinking Puppet Master might work well in conjunction with Bone Controller. Since BC uses pseudo colliders, and PM was written to work with Final IK, my guess is BC and PM should be compatible.

    Is there anyone out there trying it?
     
  42. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Yeah I was thinking that same thing... I know @Partel Lang was working on integrations with popular motion controllers and already has one for opsive's 3rd person controller so maybe @Tryz and him can work something out... I also think partel was talking about making it a single button click... but a simple integration tutorial would be fine with me...
     
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Some one else was asking about PM on another thread too.

    I'm sure that we're both trying to control the bones. So, there would probably be some initial conflict. However, if you just disable the bone motors while he is controlling them and then re-enable them when he's not... they should be fine.

    Unfortunately, there are just too many great assets out there for me to own and test them all. :eek: hehe
     
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    WOW... somehow, I totally missed this post. I'll look into it and let you know what I find. Sorry about missing it. I'm usually much better about responding. :(
     
  45. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Again, super sorry for the delay.

    I was having a hard time reproducing this and then I checked the "Run In Editor" check box in the motor details... and it happened. So, I think I understand what's going on. As we come back from play, the editor is still running the motion, but the reference to the object has changed.

    For now, disabling the "Run In Editor" should prevent the error. I'll get this resolved and put up an update.
     
    hopeful likes this.
  46. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,335
    Hey all — I've been spending the last few days frustrated with Mecanim and looking for a solution to this problem:
    • I want to use retargetable humanoid animations from several sources (Mixamo, different models, etc.) on several different humanoid characters.
    • I want to control the face animations separate from the head, e.g. so I can play a "wink" animation regardless of whether the torso/head animation is doing.
    • I also (sometimes) want to be able to make the character look at or reach for a target.
    Amazingly, you can't do this with the built-in functionality... only humanoid animations are retargetable (point 1) and support IK (point 3), but they don't let you mask arbitrary bones (point 2).

    So, in searching for a solution, I stumbled across BC, and I have to admit, it looks pretty amazing. At a minimum, I guess it could substitute for Unity's IK if I switch to Generic animations (which allow arbitrary masking). Maybe it will help with retargeting too?

    At any rate, I'd love to hear advice from other BC users (or Tim himself!) on whether this is a sensible solution to my animation problem, and what gotchas I should watch out for.
     
  47. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,962
    IIRC, you put all the facial expressions in the first layer, using generic, and make sure all your facial bones are named the same.

    I'm guessing you know all that, or I'm wrong - lol - but I put it forth in case it is of some help. :)
     
  48. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,335
    Yep, I've got that working fine with Generic animation; it just doesn't appear to work with Humanoid. (The best you can do is target one animation at the entire head, which isn't what I want).

    But another issue I hadn't even started to grapple with is hair... some of these characters have big hair, and I'd love to have it bounce, blow in the breeze, etc. Sounds like BC could make that pretty easy. I'm pretty much out of time for today, but I'm really looking forward to trying it!
     
  49. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @JoeStrout ,

    If you're controlling bones with the BC, you don't have to worry about a mask or layers. Since the BC runs in LateUpdate, it will run after animations occur. So, you can take control of individual bones and blend them with the animation as needed. It doesn't have to be a humanoid rig, but it can be.

    You're right that the BC pretty much replaces the Unity IK. You can use the included motors or create your own motor to do what you want. For example:

    Let's say you have bones that control the eyelids. So, moving the bones closes the eye lids and re-opens them. You could create a motor that uses a timer to slowly close the eyelids and then re-open them. You'd just let this motor run forever and you'd have blinking. You could also add a function on the motor that would cause winking.

    You can control all the bones separately. So your blinking motor would run and you could use the 'Look At' motor to turn the head towards a target. They'll be fine together.

    Hair is a cool idea. You can definitely use the BC to add some bounce. If you check out the demo (you probably have), the goblin's pony tail and the dinosaur's tail are a perfect example. The key will just be to make sure the hair is skinned so that as the bones move... the hair mesh moves with it.

    I think that covers it all. :)
     
    JoeStrout likes this.
  50. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,335
    I just bought BC and I'm having fun with the demos... but I thought I'd point out a bit of a hitch in the Quick Start guide. It says to add a "Bone Controller Skeleton"...
    But I don't appear have a Bone Controller Skeleton script. Nor do I have a com.ootii.Actors.BoneControllers group.



    Yet I imported everything, and the demo works... from inspecting the demos, I think what I actually want is just a "Bone Controller" script. Anyway, I know how hard it is to keep docs up-to-date, but it's even harder if nobody points out when they're off, so here you go. :)