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

Motion Controller

Discussion in 'Assets and Asset Store' started by Tryz, Feb 21, 2014.

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Just as a heads up...

    I'm going to release this as a "Climbing Pack" for free (ignore the Hallow's Deep reference):


    I'm all done (I think). I just need to create some pretty marketing material and submit it to Unity. That's just been low on my priority list.

    My guess is that you'll see it on the Asset Store in July.
     
    Last edited: Jun 26, 2018
  2. luekio

    luekio

    Joined:
    Jan 23, 2018
    Posts:
    24
    Ha! champion. I will cease wrangling third party integrations an wait for this one!
     
    Tryz likes this.
  3. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hi Tim,

    What would be the easiest way to force the Player body orientation during an attack motion?

    I know that target system will force player orientation during movement but I'd like to implement an helper for when the player attacks so it keep orientation (especially for some of my attacks that have the player jump in the air and slam the ground down some meters in front of him)

    I know that I can't force it via script as MC or AC has control during a motion play
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Actually, you can.

    Just call AC.SetPosition() or AC.SetRotation() and those values will override what the MC is sending to the AC.

    In your case, you can let the MC continue to tell the AC what the position is, but you can call AC.SetRotation() to force the character to rotate how you want.
     
    rubble1 and Necka_ like this.
  5. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Thank you Tim. So as a non good coder, I searched for a script to understand how to set rotation to an object position and reproduced it in Bolt. It works almost perfectly, almost because My character is strangely moving backward (sliding, no animation)

    As I'm not sure if it's my fault for a wrong "code" or a bug, I'd like to share it with you to be sure about what's going on:

    I've setup a little proto sequence with my character and a cube which would be my target

    I get my target position, get my character position.
    Substract the target position to my character's and normalize the Vector3
    Then I use Quaternion.LookRotation with the value from the normalized Vector3 and assign it to AC.SetRotation

    I used this code (but didn't use the Slerp as for this test I don't care about the rotation speed)

    Code (CSharp):
    1. using UnityEngine;
    2. public class SlerpToLookAt: MonoBehaviour
    3. {
    4.      //values that will be set in the Inspector
    5.      public Transform Target;
    6.      public float RotationSpeed;
    7.      //values for internal use
    8.      private Quaternion _lookRotation;
    9.      private Vector3 _direction;
    10.    
    11.      // Update is called once per frame
    12.      void Update()
    13.      {
    14.          //find the vector pointing from our position to the target
    15.          _direction = (Target.position - transform.position).normalized;
    16.          //create the rotation we need to be in to look at the target
    17.          _lookRotation = Quaternion.LookRotation(_direction);
    18.          //rotate us over time according to speed until we are in the required rotation
    19.          transform.rotation = Quaternion.Slerp(transform.rotation, _lookRotation, Time.deltaTime * RotationSpeed);
    20.      }
    21. }
    The issue in video:


    Did I forget something important?

    The set rotation will only happen in some specific cases, of course not like in this video but the behaviour remain strange to me
     
    rubble1 likes this.
  6. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I am wondering if anyone has successfully used the motion controller with the Malbers PolyArt animals? I am trying to set up the Deer and I am having some issues. Mostly because this is the first time I have tried to change up the animations on my own. I really need/want to learn to start customizing the controller and use it to its full potential with AI and behavior designer. Malbers controller is setup a little different than the MC and mostly on the blend tree for locomotion.

    Should i create my own motion or try to adapt one of the already supplied? Any nudge in the right direction would be appreciated.
     
  7. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    There is an integration for MC in Malbers asset; don't know if it's only for Horse animset pro though... could be, but it mixes the MC+HAP animators to get them to work together
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Your code looks fine. I didn't run it, but it seems like it would just rotate the character.

    I see the sliding in your video, but I'm guessing it's a customization. I don't know.
     
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    If you use the "basic" motions: Basic Idle, Basic Walk Run Strafe, Basic Melee Attack, etc. it's just a matter of replacing the humanoid walk with the deer's walk. I did something similar with the dog:



    It really wasn't anything tricky. I just replace the idle "pose", the walk, the run, etc.
     
  10. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I have probably watched that particular video about 20 times and I went that route and did not get the result I was looking for. Malbers polyart animals has a full range of motions that do not quite fit into the basic animations. For instance, the deer has 3 locomotion states, walk, trot, and run. A little too complete for the walk/run/pivot motion. I thought maybe the walk/run/strafe basic motion would work, but I am trying to put all three locomotion states into a single blend tree. The walk/run/strafe appears to separate the walk/run into separate blend trees. I assume this is to take advantage of the run (shift) key on the keyboard. Since I only plan on using the controller on these animals for AI purposes, i have no need of that and would like them in a single blend tree. (Is this assumption correct?)

    I am a coder by profession so I am just going to roll up my sleeves and dig into the code and create a new motion that will handle the animals. They all have swimming motions also and will need to incorporate that as well so i think that coding is probably the best answer. They will all be controlled via behavior designer or node canvas (I havent decided which but leaning towards behavior designer) so player input just is not needed.

    Make sense? Or am i way over thinking it?
     
  11. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I glanced at the integration and thought it was specifically for HAP. I will take a second look at it and see if it will work for his animals also.
     
  12. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I believe that I should model what is going on the in NPC Based - Animset Pro Motions available from the vault website. I also think that the following two videos from the ootii youtube channel will get me going in the right direction.



     
    Tryz likes this.
  13. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    If you were dealing with player input, I would say you could use Basic Walk Run Pivot and that is a single blend tree. However, its rotation scheme doesn't work well when the character is controlled by AI. Since you mentioned there's no player input, Basic Walk Run Strafe would be the way to go. Except, the animals don't strafe.

    I also agree that Malbers has a lot of great animation detail that the basic versions of my motions won't support out-of-the-box.

    I was just playing with his Tiger animations and while I set it up with Basic Walk Run Pivot quickly, it wasn't nearly as satisfying as it could be.

    So, all that said... I think you're right about creating motions that are specific to Malber's animations. This way you can take advantage of his turns, transitions, etc.

    My videos are the right place to start. Also check out the motion builder's guide:
    http://www.ootii.com/unity/motioncontroller/MCMotionBuilder.pdf

    Skim through the pictures and you should be fine.

    One suggestion I'd have... start small. Just start with a simple idle. Once you get that working and understand the flow of the motions, do a simple walk forward. Then, start building off of that. Some people jump into really complex motions (ie parkour) without really understanding the flow and it gets frustrating fast.

    I'm always here to help (or at tim@ootii.com).
     
    hopeful likes this.
  14. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Try simply adding another animation to the blend tree at 0.75 (walk is 0.5 and run is 1.0). You'll want Always Run set for AI controlled characters, and in your BT nodes you can set the speed between 0.5 and 1.0 to get the movement you want.

    It's mainly organizational. The code just sets the animator parameters used by the blend tree. Full strafeset blend trees have 8 animations for each movement speed, so it's a bit unwieldy putting them all in a single tree.
     
    Tryz likes this.
  15. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I went this route last night and while it worked somewhat, it still looked clumsey when running. I am sure that i could have tweaked values, etc and got it working. However, I believe that creating a new animation thru code will probably be my best bet and give me full control over duplicating what Malbers has already done. I have not even looked at the swim logic portion of his controller and I will have some work to do to get that included also.

    The good news is that all of his animals basically use the same controller with different animations added so once i get one done i can copy/paste the others.

    Going this route will also allow me to randomize the different idles, attacks, etc. Plus it will be a good learning experience. :)
     
    Tryz likes this.
  16. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    In the that case, I'd suggest using the Motion Form parameter in your custom motions (as with the Basic motions) so that you can re-use those same motions with all your Malbers animals. I have previously gone the route of building a set of motions for each of Kubold's weapon animation packs by copying and editing the scripts for the first, and it was a royal pain (tedious, error-prone, and a nightmare to maintain). As I understand it, my griping about that was rather influential in bringing about the BasicX motions we have today. ;)

    For the swimming animations, you may be able to adapt the Swimming Motion Pack. I suspect the animations are structured quite differently, but once you've built a ground-based movement motion, you should have the knowledge you need.

    For random idles, if you grab my old Movement Animset Pro motion pack from the Vault, you can adapt the approach I took. Each idle is weighted so that the "looking around, scratching his head" doesn't play as often as the "standing mostly still" animation. I also included an editor--definable range for random animation speed (defaults to +/- 15% IIRC) that resets back to 1 when the idle motion completes (so it doesn't affect anything else).
     
    KeithBrown likes this.
  17. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    If the controller is the same for each animal, why couldn't i just copy the controller and replace the animations?
     
  18. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    You can. Sorry, I thought you meant copy and paste your motion script to create new ones for each animation set. :)

    The major downside to copying the controller and replacing the animations is that you lose the ability to generate your animator state machines from script -- which is actually an extremely handy feature to have, even if you don't intend to share your motions with others. Being able to duplicate the clean "Humanoid" animator controller from the base Motion Controller installation and perfectly recreate all of my animator states in pristine form has saved me a lot of troubleshooting headaches, as it guarantees that there are no changes made inadvertently or which I forgot about.

    However, I would consider creating a MotionPackDefinition that can generate all of the necessary animator states and configure the character automatically to be an "advanced" task. It's not something to start out with.
     
  19. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    I just started playing with this again and was wondering about the orbit camera. Is there a way for it to Orbit around the player, i.e. so I can see the player's face. Also, am I missing something as far as the camera collision handling?

    Thanks.
     
    Last edited: Jun 28, 2018
  20. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Welcome back. :)

    The Orbit Rig that comes with the MC does do this.

    When you press one of the 'Movement Styles' buttons on the basic view, a 'Camera Rig' component will be added and the 'Main Camera' will be put as a child.

    On that 'Camera Rig' component, you can put the Orbit Rig instead of the Follow Rig. With that, the mouse will have the camera orbit the character and even go in front so you can see the player's face. You may have to hold the right mouse button, but that depends on the settings of your Input Source.

    I hope that makes sense.
     
    TeagansDad likes this.
  21. Ssssilk

    Ssssilk

    Joined:
    Jul 28, 2014
    Posts:
    12
    Hey there,
    Looking to check out the Shooter Pack you offer, but I see this in the description:
    Requires: Mixamo's free Pro Rifle Pack

    It looks like Mixamo doesn't offer that download anymore?

    Is there any other options? Would love to try it out!

    Thanks.
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I click the link and it's the first 'tile'. It's called 'Pro Rifle Pack'.

     
    Last edited: Jun 29, 2018
    TeagansDad likes this.
  23. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Only if you're already logged in or your browser has your Adobe credentials stored.

    Otherwise, you just get the Mixamo landing page.
     
    Tryz likes this.
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Good catch. Mixamo requires you to login before downloading or searching.

    Logging into Mixamo is always step #1 with Mixamo.com.
     
    TeagansDad likes this.
  25. Ssssilk

    Ssssilk

    Joined:
    Jul 28, 2014
    Posts:
    12
    Awesome, thanks!
     
  26. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Yeah, that's what I've got. Still no dice.
    It appears the on the Camera Rig, the "Orbit Rig" Anchor is the Player (or Camera Anchor - doesn't seem to matter) and on the Camera Anchor, the "Base Camera Anchor" Target is the Player with no Rotation Target. Not sure if this is right but I believe this was out of the box in the "demo_Shooter" scene.

    I'll play some more. By the way - is there a way to limit the camera rotation?
     
    Last edited: Jun 29, 2018
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Is your character rotating with the orbiting camera? Maybe on your motion, you've got "Rotate with Camera" checked.

    What motion are you using to walk with? Using one of the 'strafe' motions forces the character face the camera direction so you can strafe.


    There's really nothing tricky with the Orbit Rig. Here's what I just did:

    1. Started a new scene
    2. Added a floor and my Proto character
    3. Added the MC to Proto
    4. Pressed the 'Adventure Style' movement style button on the MC
    5. Clicked 'Camera Rig' and replaced the rig component with my Orbit Rig (I own the CC so, that was put on by default)
    6. Assigned the Input Source and Anchor on the Orbit Rig
    7. Hit play
    8. Held the right-mouse-button and orbited the camera to face Proto





    With the included Orbit Rig, you can't limit the rotation. It's just a basic camera. With my Camera Controller asset, you can.
     
  28. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    My apologies, I was using shooter style :O

    So what does the Adventure Style do differently to the Camera? I am trying to modify the demo_Shooter scene with no success.
     
    Last edited: Jun 29, 2018
    Tryz likes this.
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Adventure Style is more like Tomb Raider or Assassin's Creed. It is a modern 3rd person behavior that allows the character to face the camera.

    The Shooter Style is more like The Division where the camera is always behind the character. That's why you can strafe. If the camera is always behind the character, hitting the A/D keys has the character strafe left/right and the camera strafes with them.

    I talk about this more in the documentation (page 17)
    http://www.ootii.com/Unity/MotionController/MC2Guide.pdf

    The properties on the motions can help customize the movement too. What are you trying to modify?
     
    TeagansDad likes this.
  30. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    I'm giving you a hard time but I have to say, I still have no idea how you get the frame rates that you do. Blows Invector & Third Person Cover out of the water.

    One last thing. I have a REALLY messed up rig, the initial bone is not rigged at 0,0,0. Since I no nothing about 3d modelling and rigging I used Puppet3D to modify it. It does some interesting things but now I can't seem to re-target the guns from my "original" rig's WeaponHolder to Puppet3D's mirrored rig WeaponHolder_JNT.

    I can't find in your code where you map your weapons to WeaponHolder.
     
    TeagansDad likes this.
  31. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Nothing, that's it. I was just trying to get that view. My lack of understanding - I don't play many video games :)

    BTW - The Camera Controller does look pretty cool. I'll wait for the pay check.
     
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thanks. :D

    I'll assume you're talking about the Shooter Motion Pack (or any of the other weapon packs).

    I use Basic Inventory's slots. The name of the slot matches Unity's Human Body Bone name or a transform name. When it does, I automatically attach the weapon to that transform.

    I describe that more here:
    Basic Inventory



    In the image above, the word "RIGHT_HAND" matches UnityBodyBone's "RightHand" (I don't care about capitalization, underscores, or spaces).

    So, the Weapon Set says to put the Sword_01 into the RIGHT_HAND. If you want it to go into a specific transform, you could replace "RIGHT_HAND" to "WeaponHolder_JNT" (or whatever you named the transform).
     
  33. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Thanks for your help
     
    Tryz likes this.
  34. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Not really sure if this is the place to ask but... I am work with the shooter pack and I have a number of gun (pistol) models. All of these models have the z-axis pointing in the wrong direction, not down the barrel (not really sure why they all do that). When I Play and this gun gets instantiated in the RightHand of my player, the players body contorts.
    This has also happened in other 3rd person controllers. I have even parented the gun underneath a GameObject with a proper z-axis.

    Any help would be great.
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    This is the fun of working with different artists on the asset store. :)

    What's happening is that the 'Enable Look IK' on the Basic Shooter Attack and Basic Shooter Empty motions are using the barrel's direction to rotate the spine bones for IK. This is what allows the character to look up and down when aiming and shooting.



    It's also what what helps fix the left/right rotation a bit when the blending of animation layers causes the spline to not really face forward.

    So, first step is to just uncheck the 'Enable Look IK' and see if the body stops contorting.

    Check out this page to learn more:
    Shooter Tips & Tricks

    Since the gun itself is built in an odd way, I'd create the prefab for the gun and nest it. You mentioned this, but is the GameObject part of the prefab?

    The other thing to try (even without the nesting) is modifying the Local Position and Local Rotation of the Gun Core that is on the gun. In the end, that's really how the gun is attached to the hand. You would be able to customize the rotation to match the hand bone transform and the gun transform.

    Check out this page to learn more:
    Gun Core Local Position and Rotation
     
    TeagansDad and jnbbender like this.
  36. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    Is there a motion pack or a method of getting Breath of the Wild styled terrain climbing for this?
     
  37. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Thanks so much. I really don't mean to be such a pain but I am trying to get my Player setup in an empty scene before I "go forth" when I started seeing the effects below whenever I would shoot the gun. I put my character in the demo_Shooter scene and all was good. The gun I used in the scene below was my own but the properties were taken from the Glock_Mixamo gun.

    Any ideas?
    Untitled.png
     
    Last edited: Jul 2, 2018
  38. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Look some posts above (not so long ago); a Climbing pack will be released for free very soon now
     
  39. jessejarvis

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    If you're talking about 'Hallow's Deep - Climbing Alpha 1' that has cliff/edge climbing but not climbing steep mountains/terrain.

    Thanks though!
     
  40. luekio

    luekio

    Joined:
    Jan 23, 2018
    Posts:
    24
    There is some basic freeclimbing already built into the motion controller. You just have to turn it on.

    I'm eagerly awaiting the climbing pack though, I think we really need that and a good roll. Depending what the pack is like, perhaps we (the community) can collaborate to flesh out the controller?

    I'm a film animator by trade and could contribute animation, if anyone is competent to do the coding...
     
    Last edited: Jul 2, 2018
    Tryz likes this.
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Not one that has the kind of "free climbing" in Breath of the Wild. It's doable, but not what I did for this release.
     
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'm wondering if that's a bullet hole that is stretched due to the scale of the ground.

    When I place the bullet holes, I may need to counter any existing scale first. I'll do some tests.
     
  43. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    @Tryz I scaled the Plane (10, 1, 10). Actually, this occurs when I miss the cube. When I hit the cube the bullet holes get placed.
     
    Last edited: Jul 3, 2018
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Then I don't think it's something I'm doing. It actually looks like stretched geometry. You should be able to see it in your hierarchy.

    I noticed you are using the Pistol Animset. You may want to see if the animations are modifying geometry unexpectedly.
     
  45. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    I'll check it out. I haven't incorporated Pistol Animset yet but I'll wipe it in case there's a conflict and I'll check out the geometry.
     
  46. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    @Tryz Well, turns out the Plane geometry was the issue. I changed it to (10, 10, 10) - problem gone. It was then that I noticed the Plane in your shooter demo was set the same.
     
    Tryz likes this.
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'll see about adjusting for the scale. I thought I did, but I must of missed something.
     
  48. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    @Tryz Ok, I'm really not trying to be a pain but I added one of the walls from your shooter scene and it worked fine. So did a couple of my simple walls, just standard cubes scaled up. I shot at them for little and started to see the following. They got a few bullet holes but then I saw the streaking. What I don't understand is this character work fine in your shooter demo scene AND my scene is a simple plane with some cubes.
     

    Attached Files:

    Tryz likes this.
  49. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634

    Just curious what are your plans moving forward? any more packs? some new tool, or something else? just wondering, its been awhile, since I asked. and I been out of the loop, so I was just curious.
     
    Tryz likes this.
  50. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Not a problem. I should handle the non-uniform scales. :)