Search Unity

Bone Controller [RELEASED]

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

  1. nidhogge242

    nidhogge242

    Joined:
    Jul 21, 2016
    Posts:
    9
    Hey this looks like a sweet asset. Do you know if it would work together with Puppet2D?
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @nidhogge242 ,

    I don't think it will.

    The Bone Controller is used in 3D solutions and uses Unity's standard transforms. I'm not sure if 2D games uses those. If they do use transforms, it might. However, I just don't know.

    I'm sorry. I wish I had a better answer for you. :(
     
  3. Ai_Player

    Ai_Player

    Joined:
    Feb 18, 2013
    Posts:
    5
    Hi everyone im itchy,
    I had already upgraded to Unity 5.6 before i downloaded and imported Bone Collector.

    I started working thru the Quick Start and got to step 5 in "Your First Scene"

    5. On the character, let’s add a Bone Controller Skeleton
    - Add Component
    - Scripts
    - com.ootii.Actors.BoneControllers
    - Bone Controller Skeleton

    I can not find the Bone Controller Skeleton anywhere.

    i go to scrips com.ootii.Actors.BoneControllers is not there.

    when i enter Scrips it starts with com.ootii.Base
    then com.ootii.Camara
    com.ootii.Demo
    com.ootii.Geometry
    com.ootii.Utilies.Debug

    but there is no com.ootii.Actors

    I know i'm pretty green at this but am i doing something wrong. I just bought Bone Collector tonight.

    Help ?
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi Itchy,

    I'm sorry about that. I'm not sure why it's not there, but you're right.

    Do this instead. Click the 'Component | ootii | Bone Controller" menu at the top of Unity. That will add it too.

    I'll look why it's gone and update the docs...

    Docs updated. :)
     
    Last edited: Apr 6, 2017
  5. Ai_Player

    Ai_Player

    Joined:
    Feb 18, 2013
    Posts:
    5
    Hi Tryz, thanks for the reply . .. . I did this but it only adds the Bone Controller and not the Bone Controller Skeleton like it shows in the quickstart.
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Bone Controller is the Bone Controller Skeleton.

    As you look through the documentation images and follow the steps, you'll see they are exactly the same. It was just a name change a while back and I must have forgotten to update the documentation.

    Make sure you check out these videos too. They will help you walk through things as well.
     
    Last edited: Apr 6, 2017
  7. Ai_Player

    Ai_Player

    Joined:
    Feb 18, 2013
    Posts:
    5
    ok , thanks again Tryz. .
     
    Tryz likes this.
  8. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi Tim,

    Just bought bone controller to use with motion controller as well. Any chance to add an aim motor for the bone controller? Or can we use a look at in some bones to get the same. I haven't play with it yet, but it is the main reason i bought it.

    Thanks and good work as allways!
     
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @Danirey ,

    The Look At motor is what I would consider an "aim motor" (if we're thinking the same thing). Given a target, it rotates the head, neck, spine, and other back bones. This allows you to face the target.

    What you'll want to do is determine when to enable and disable the motor. Maybe it's on a key press or during a cut-scene. One thing you can do is use the motor's weight (0 to 1) to ramp up and down the weight so that it enables (1) and disables (0) smoothly.

    I hope that helps.
     
  10. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi,

    Thanks for answer. I'm talking about aiming with a gun for example. i want the gun points to a point/object, and all connected bones move according that.

    Tha thing is that the gun will not have a bone because it will not be part of the character skeleton, so how can i face this?

    Thanks a lot!
     
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Since the Look At motor can twist the spine, it's still a good solution. You just want to change the bone weights so that more of the rotation occurs on the spine and less on the neck and head. That spine twisting will cause the arms to rotate to the target too. Typically, most aiming (even for guns) is done from twisting the spine.

    If you really want to have the arms move (say you're facing forward and you want your arm to shoot 90-degrees to the right), you can use a Limb Reach motor. That will pull the arms towards the target and move it up, down, left, and right.

    Since the gun doesn't have a bone, we can't use it with the Bone Controller. That means you have to place and rotate it manually as you need. But, we can use the spine, arms, hands, etc.

    I'm assuming the gun eventually attaches to the hand and becomes a child. So, it will rotate and move as the hand bone rotates and move. So, it will follow the Look At motor and the Limb Reach motor.
     
  12. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    I think i got it. Let's try and i'll let you know if i can make it work. ;)

    Thanks a lot for the help!
     
    Tryz likes this.
  13. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi I'm sorry but I can't get the Aiming setup working. Any chance to get a more detailed setup steps? I tried using limb reach motors for both hands but I have some problems. I suppose you are busy with all your stuff, but some day would be a good idea to give a tutorial showing the basics for a shooter setup, not only for swords. :)

    Thanks again.
     
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Give me a day or two and I'll put together a quick example.

    I'll probably use a Mixamo rifle animation and just use the Look At motor. :)
     
    hopeful and Danirey like this.
  15. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hey thanks. That would help a lot. I use mixamo rigs, so it is fine!

    Cheers!
     
  16. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    Is it possible to do foot IK with only 2 bones? My cartoon creature only has 2 bones in the legs (upper part and lower part) :)
     
  17. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Yes, but with a little trick.

    Once your character is in the scene and before you add the BC, add an empty GameObject as a child of your lower leg. Move it to the end of the lower leg... where the foot would be.

    With this, each leg would have 3 bones (2 real and 1 fake). Now you can setup the BC and use the foot IK motor like normal. In the inspector for the motor, just remember to uncheck "Rotate Foot to Ground".

    Hopefully that makes sense.
     
  18. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @Danirey ,

    Here's the video I promised. Let me know if you have any questions.
     
    TeagansDad and Danirey like this.
  19. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    It is perfect. Thank you so much!
     
    Tryz likes this.
  20. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    @Tryz

    It doesn't seem to be working correctly. I tried setting up the system as you suggested but when it react to the ground it only reacts if a box is moved under the foot, very slowly and doesn't react to the floor it standing on even though they are the same layer. Also it's like it is not updating as it doesn't fall back down to the ground position when moving the box away from the foot.
     
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    It really is just a matter of adding a GameObject to represent the feet as I mentioned. The rest is just standard setup that I describe in the docs and videos.

    I went ahead and put together a quick video for you.


    Once you add the extra GameObject to represent the feet, everything else is just normal setup. It's probably worth looking at this video as well as it walks you through setting up the foot motor. Your character may be different than my example and need an extra adjustment that I talk about.


    The foot motor is simply doing a raycast down. So, if your ground and box are on the same layer, it will find the ground (if the ground is in range).

    One other comment I'd add is that the foot motor won't pull your feet or legs down; your animation does that. Take a simple idle animation...

    Each frame, Unity runs the idle animation and moves the leg bones to an extended position based on how the animation was created. After that, IK runs and adjusts the bone rotations based on the environment.

    The next frame, the old IK doesn't matter. The animation goes to the next frame and moves the leg bones to an extended position. After that, IK runs and adjusts the bone rotations based on the environment.

    It's the animation that "resets" the bones each frame. So, the foot IK doesn't need to pull anything down. If you have no animation, then the bones will stay how the IK put them.
     
    Last edited: Apr 24, 2017
    TeagansDad likes this.
  22. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    @Tryz

    Thank you soooo much! Best support ever! :D
     
    TeagansDad, hopeful and Tryz like this.
  23. dmoroni

    dmoroni

    Joined:
    Mar 10, 2015
    Posts:
    23
    Hi Tryz, I'm very impressed by your Bone Controller and I think it could be very useful for a project i'm working on.

    The project is a Multiplayer VR game, with two players fighting with guns that shoot (virtual) water balloons. The real users wear a GearVR headset, with their body movements tracked by a Kinect. Plus, they grab a Wii controller in their hand to aim and shoot.

    Since the game is developed for Android, I can't directly use the Kinect PC integration to control the avatars. So, instead of mapping the whole skeletal data on the avatar's bones, I would try to use the Kinect raw data + GearVR head orientation + Wii position/orientation to drive some Bone Controller motors. In detail:

    - Use the BaseSpine transform from Kinect to move the whole avatar
    - GearVR head orientation to drive a LookAt motor on avatar's head. Possibily some other BC motor to correctly position avatar's head (user's head position comes from Kinect).
    - Hands transforms from Kinect + Wii controller transform to drive Limb Reach Motors on arms.
    - Feet transforms from Kinect to position the avatar's feet, with Foot Placement Motor on
    - Finger Pose motor to have the character grab the gun.

    In short, I would simply use some of the data from the input devices and let the Bone Controllers IK do all the job. Does it make sense for you? Any hints appreciated too :D

    Thanks!
    Riccardo
     
    Last edited: Apr 28, 2017
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi Riccardo,

    Wow. I can't say the BC has been used like this before.

    The thing with some of the motors is that there is typically a 'target' that is used to control the rotation of the bones. Take the LookAt motor for example. There's a target property and the motor rotates the bones based on the direction to the target. So the GearVR head orientation wouldn't really rotate any bones... the motor logic does based on the target position.

    I'm thinking what you really want is the Pose motor. With this motor, you can set which bones will be controlled by the motor and a rotation. With a little bit of code, you could have the GearVR head orientation update the neck bone in the pose motor and that would make the character's head turn.

    That's probably true for the Hands transform. Although, you might be able to use the hands transform to control a target that the Limb Read Motor would use.

    At a low level, you can definitely control the skeleton through the BC directly. My only worry is that the motors I have may not be the best way to do it for your situation. You may need to modify or even create a new bone motor... which is totally acceptable.

    I hope that helps!
     
  25. dmoroni

    dmoroni

    Joined:
    Mar 10, 2015
    Posts:
    23
    Hi Tryz, thank you for your answer.
    I've surely been too concise in my explanation but this is exactly my idea, that is using the input data to move some GameObject and use it as a target for BC motors.

    For the character's head it could be a combination of head position coming from Kinect and the orientation from GearVR, to have something like: targetPos = headKinectPos + headOrientationGearVR.forward.
    I could position a GameObject there and use it for the head LookAt.

    For the hand grabbing the gun i could use the Wii controller transform to move/rotate another GameObject (the gun itself, indeed), using it as a target for the Limb Reach motor.

    Anyway, your hint about the Pose motor is great too, i think it could be very useful in some of those situations.

    Just another question: is there a way to control orientations in Limb Reach motor, or is it just limited to positions? Using it the way i imagined it should be necessary to rotate the hand and maybe to have some rotational control on the elbow.
     
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Good stuff!

    It's really limited to positions. I tried to make this motor as natural as possible for arms and legs. So, it tries to keep the elbow and knee orientations close to the original pose as possible.

    Of course, creating new motors is totally doable. I'll admit that working with quaternions can be a bit tricky, but a lot of the grunt work I try to handle. The Pose motor is a great some-what simple example.
     
  27. dmoroni

    dmoroni

    Joined:
    Mar 10, 2015
    Posts:
    23
    Happy to hear that, if the limb's orientation stays rather natural i could even do without controlling any rotations at all.

    Anyway it won't be a problem for me to derive some new motor class that could better fit my needs, and i already saw your documentation is really clear and complete.

    Thanks again for your answers, i'll sure have a go with Bone Controller.
     
    Tryz likes this.
  28. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    i have a punch animation that i want to punch a wall.. the animation is passing through the wall even with rigidbodys and colliers. So my question is, can i use ik to stop the animation when it detects the wall / colliders ?
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    It would require a custom BC motor, but with that customization... yes.

    I'm not sure IK is your best solution though. Lets say the fist hits a wall half way through the animation. The IK would keep it from going through the wall, but you'd have your fist touching the wall for a second or more waiting for the animation to retract it. The reality is you probably want the fist to hit the wall and retract right away.

    That means you would either jump the time of the animation or play the animation backwards from the hit point... depending on how the animation was made.

    You don't have to do it that way, but it's something to think about.
     
  30. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi,

    Any way to priorize the motors when several affects the same bones?

    Thanks!
     
  31. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The motors run in list order. So, the last one in the list wins (assuming its weight is 100%).

    You can have several motors working on the same bone and blend them using the Weight property. But, they won't block each other.

    Managing the motor weights and if they are enabled would be something you'd control as part of your game-play logic.

    Doing it automatically per bone would be tough as most motors work on multiple bones. I'm not sure how hairy it would get trying to determine if the LookAt motor contradicts the LimbReachMotor.
     
    Danirey likes this.
  32. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Ok, I'll try changing the order,Maybe reorderable list could be a great update.

    I'm trying t set two different poses for both arms. First both arms up and the other both arms down. If i clic the mouse butom the arms up weight is lerped at 1 and the other to 0. Is this the way to do that?
     
  33. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Yes. That should get a smooth transition from one pose to the other.
     
  34. Falagard

    Falagard

    Joined:
    Jan 8, 2014
    Posts:
    43
    Is it possible to use ik at edit time to create animation clips?
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You can use most motors at edit time, but I don't do anything to with creating animation clips.

    I hope that makes sense.
     
  36. Fabbs

    Fabbs

    Joined:
    Dec 2, 2013
    Posts:
    43
    Hello! I wonder if Bone controller could work with first person hands/arms to lets say, push a specific button or put hands up to a wall or something like that. Thanks :)
     
  37. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Absolutely.

    The BC uses "motors" to control bones for different reasons and different times.

    In these cases, you'd use the Limb Reach Motor to pull the hand to a specific target (say button, wall, etc.). Then, you could use the Finger Pose Motor to bend the fingers to a "press the button pose" if you wanted.

    If you needed, you could create your own motor that pulls these two motors together or adds wrist bending or something.
     
  38. Fabbs

    Fabbs

    Joined:
    Dec 2, 2013
    Posts:
    43
    Perfect, thank you!
     
  39. jpatinop80

    jpatinop80

    Joined:
    Jul 29, 2012
    Posts:
    55
    Hello, Nice asset, I would like to know if could work for my propuse. I need to create a "character animator live" so user can create some kind of customs animations like run, jump stretch, etc. the thing is, this could be used to control all movements of the character or predefine with slider how to move i.e the arm, leg, etc and record this animations to use them later?, I really don't know how much your asset can do..so, you think I can use BC for some or all my needs? thank you
     
  40. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi @jpatinop80 ,

    While the BC will let you control predefined "poses" with a slider, it would not record animations for use later. It sounds like the BC isn't really a fit for your project.
     
  41. Vanidash-Studios

    Vanidash-Studios

    Joined:
    Mar 9, 2016
    Posts:
    71
    Hi, i just downloaded this asset, im having 2 problems when trying to set it up:
    1. The function "Only show selected bones" when its checked wont show anything, even if i select a bone with the "hand" grab tool, i can see the bone being selected (Its yellow) but in the inspector it wont show more details about it.

    1.png

    2. When i add the foot to ground motor, after i move the step (Just like in the example tutorial) the foot will move as im moving the step upwards but the problem is that after i move it back downards the foot will remain in the higest position instead of going back to normal.

    2.png

    Im using unity 2017.2

    *Edit: I discovered that moving the step downward very slow will allow the foot to go back to its normal position, but i still dont think this is the way its suppose to work.
     
    Last edited: Dec 3, 2017
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I just created a new U2017.2 project and imported the latest BC. The "Only show selected bones" is working for me and a Mixamo character. Maybe there's something different about yours. Can you send it to tim@ootii.com?

    It's because you're not running an animation. Your Animator's Controller field is empty.

    The foot IK will force the foot up, but it won't force it down. Your animation does that.

    If you think about the flow each frame, it will make sense...
    1. Animation runs and poses the character
    2. IK overrides animation

    1. Animation runs and poses the character
    2. IK overrides animation

    etc.

    In your case, you have no animation that is posing the character.
     
    TeagansDad likes this.
  43. Vanidash-Studios

    Vanidash-Studios

    Joined:
    Mar 9, 2016
    Posts:
    71
    Ok, the missing animation will explain it, i will try to re import the asset and see if it works when selecting the bone.

    Thanks again for the quick reply!
     
    Tryz likes this.
  44. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    We're seeing some major spikes in the profiler caused by Bone Controller. Our main character model has 7 motors (because it's a quadruped). And it looks like the BC update allocates 0.8MBz every frame, and then calls GC every n frames to collect that. When we have a dozen NPCs (also quadrupeds with 7 motors each) spawned, on my computer the GC spikes are very frequent, more than one per second. And there are some "object pools", which probably are supposed to save allocations, but resizing those seems to be where the allocations (and GC) happen. BC seems to add items of "IKBoneModifier" to a pool every frame, and the pool grows in size to at least 10,000.

    We did make one modification to BC (which only calls the BC LateUpdate directly from our own LateUpdate instead of the normal call in order to get this to happen after certain things but before certain other things..), but we sure hope you can give some pointers about how to improve this....
     
  45. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Can you list the motors you're using and are you using joint constraints?

    [EDIT]
    I setup two foot motors and let it run for 5 min. 0 GC allocation and consistent IKBoneModifier allocations.

    I'm doing my IKBoneModifier releases in Update() at line 1035. Any chance your change has stopped that from running?

    Once you send the other motors, I'll check them too.
     
    Last edited: Dec 6, 2017
  46. TommiH

    TommiH

    Joined:
    Jan 14, 2008
    Posts:
    253
    Hello Tryz,

    gecko's programmer here. We're using four Foot to Ground 2 Bone Motors, two Limb Reach Motors, and one Bone Chain Drag Motor. My change should not affect Update calls at all - it just calls LateUpdate from my LateUpdate scripts (and I renamed it to DoLateUpdate so it won't update by itself).

    I'd test the Update call, but I can't find it. Line 1035 in BoneController.cs looks like this:

    Code (csharp):
    1. if (EditorForceTrueColliders && (rBone == null || rBone._Transform == null || rBone._Transform.gameObject == null || rBone._Transform.gameObject.GetComponent<Collider>() != null))
     
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Ah. No... I should have been more specific. That's Line 1035 of the BoneControllerBone.cs.

    IKBoneModifier is allocated with:
    IKBoneModifier.Allocate(...);

    and released with:
    IKBoneModifier.Release(...);

    In order for the pool to get up to 10,000, they must not be being released. That would probably mean that Line 1035 of the BoneControllerBone.cs (which calls IKBoneModifier.Release(...)) isn't happening at the right time. You may want to put a break point there and see if this is ever getting called. It's possible that your change has this release happening at a bad time (or not at all), but I'm not sure.

    I'm also curious if you see these issue in an unmodified version of the BC... maybe one of my demos.

    I'll try out the other motors you listed as well.

    It may be easier to do this through email than here on the forum. If you shoot an email to tim@ootii.com, I'll be happy to help.
     
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    @TommiH and @gecko ,

    I created a scene with two characters that includes: 4 Foot to Ground motors, 2 Limb Reach motors, and a Bone Chain Drag motor. After 5 minutes, it's still running 0 GC and no run-away IKBoneModifiers.

    At this point, all I can think is that the issue has to do with the code you modified.

    My suggestion would be to do a test like I did with a non-modified Bone Controller and use that as a base. Then, you can do comparisons with your modified code.
     
  49. Apposl

    Apposl

    Joined:
    Nov 27, 2017
    Posts:
    50
    Does this work with Final IK, or do they both essentially do the same thing?

    I am interested in the ability to make bones out of static meshes. I have 2 NPC 3D models that have 4 legs, but they're not rigged. Unsure how to start getting them animated and just walking around, but I think bones is the first step. :)
     
  50. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The BC and Final IK are pretty similar. Mine is more character focused with motors for specific tasks while Final IK is more generic.

    You can make bones out of static meshes with the BC. However, I hesitate to say "rigged" as that typically means vertex weighting with skinned meshes and I don't do that. You also wouldn't be able to animate with the BC.

    You might want to check out UMotion. It's a pretty impressive animation tool.
     
    Apposl likes this.