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. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey guys.

    I have a skinned mesh that is both my sword and shield. is there a way to set the motion / actor controller to know that these are equipped from the beginning instead of running the equip motion?
     
  2. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    Will do, no, this happened even when I opened the demo scene for the first time.
    It's very confusing, since I can't figure out the cause of it(it happens not very often and feels like this input was just ignored).
    And it creates even more problems now, because I use it for a multiplayer game with server authority. This results into character sometimes acting differently on the client and server, which messes with my lag compensation.
     
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    For a standard mesh sword, you would put the sword in the characters hand. Then you would set that sword as the "instance" property on the Item that represents your sword in the Basic Inventory.

    The other option is to start without the sword in hand and during your game start, call the EquipItem function that is on Basic Inventory. Do this before the player sees the screen.

    To be honest, I'm not sure how to handle a skinned mesh that is both the sword and shield. It's not a setup I expected.
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Can you send me the simplest project this is happening on? Preferably a new project with just the MC and my demo scene if it happening then. If not, let me know.

    I want to help, but my assets have been out for years and no on has reported this. So it has to be something unique to your keyboard, assets in your project, Unity Input Manager settings, etc.
     
  5. borkbork

    borkbork

    Joined:
    Jul 5, 2014
    Posts:
    64
    Curious about rope climbing & swinging. I've seen it mentioned a number of times in the forum but nothing concrete. Is this something that could be done with MC? I'm not afraid to do the work to figure it out, just wondering if it would be worth it/possible?
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    It can be done, but it would be a harder motion to create due to the animation coordination with the ropes.

    Motions connect the character, animations, and the environment using code. So you really can do anything through the framework. You just have to have the animations and be able to create the code.
     
  7. borkbork

    borkbork

    Joined:
    Jul 5, 2014
    Posts:
    64
    Thanks Tryz, I'm glad to hear that. Also wondering about ragdoll. From what I've read in the forum it sounds like this is on the dev agenda? Perhaps possible integration with Puppet Master?
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Ragdoll is is something I'd like to get to, but I wouldn't expect to for a long time. Other assets like Puppet Master do work. He had an integration with MC on his site. I'm not sure if it's still there.
     
    borkbork likes this.
  9. borkbork

    borkbork

    Joined:
    Jul 5, 2014
    Posts:
    64
    Thanks again. Yep, found the integration package in the PM forum. Awesome!
     
    Tryz likes this.
  10. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    32
    Hello I have a question about interaction system - I'm able to trigger the actions in the demo by pressing 'f' to interact, but how can I trigger it another way, such as with a UI button? I need to character to use the Force Position and Force Rotation functionality on the interactable core object before beginning the interaction. Seems simple enough but I've had a tough time finding a solution, help would be appreciated. Thanks!
     
  11. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey cspid,
    To call it through code, first grab the BasicInteraction from the Motion Controllers GetMotion() function. I show examples in the documentation. Then, call TestActivate() on that motion. If it returns true, activate the motion using the Motion Controllers ActivateMotion() function.

    On the InteractableCore you put on the object, you can set the target position and rotation.

    Search www.ootiigames.com for 'interactable' or some thing like that and you will find documentation.
     
  12. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    I think I found the issue, probably, was my fault after all, at least it stopped happening for now. Will let you know if it comes back.
     
    Last edited: Jul 10, 2019
  13. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    32
    Thanks so much for your response, that did the trick. I'd like to ask one follow up - now that I've triggered my animation, I'm getting some unwanted behavior which seems to be root-motion related. To highlight the issue I've called the same animation from the same position on two different characters. The character in blue is using a fresh animator using rootmotion with no Ootii components, and displays the animation correctly. The other uses the Ootii motion controller and actor controller with the animation called with ActiveMotion().

    Any help appreciated, thanks.
     

    Attached Files:

  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    How are you having the ootii character walk and then pivot?

    It looks like the character isn't rotating when sitting. What motion is running to sit? You can look to see if the one your using is clearing rotation in the UpdateRootMotion function. Some do on purpose.
     
  15. cspid

    cspid

    Joined:
    Apr 25, 2014
    Posts:
    32
    The ootii character walks to the spot with Basic Walk Run Strafe, I then rotate and call the basic interaction motion for my custom animation - the one that plays on both characters.
    Code (CSharp):
    1. motionController.SetTargetRotation(target.rotation);    
    2. motionController.ActivateMotion(motionControllerMotion);
    Thanks again for your help
     
  16. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    Removed part of this post cause I thought I managed to fix it but nay.

    I am struggling to override orbit rig. I need to force it to accept certain angles. But neither modifying transform, nor setting yaw and pitch works. It keeps messing up my lag compensation.

    I simply want to force it to teleport to a given rotation.
     
    Last edited: Jul 10, 2019
  17. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey Ootii experts.

    i have a problem that i hope any of you guys can help me with.

    When my player attacks NPC's i want to give them a chance to block/dodge the incoming attack. For this i attempted to create a custom reactor that looks like this

    Code (CSharp):
    1.     /// <summary>
    2.     /// Used to test if the reactor should process
    3.     /// </summary>
    4.     /// <returns></returns>
    5.     public override bool TestActivate(IMessage rMessage)
    6.     {
    7.         if (!base.TestActivate(rMessage))
    8.         {
    9.             return false;
    10.         }
    11.  
    12.         if (mActorCore == null || !mActorCore.IsAlive)
    13.         {
    14.             return false;
    15.         }
    16.  
    17.         if (rMessage.ID != CombatMessage.MSG_DEFENDER_ATTACKED)
    18.         {
    19.             return false;
    20.         }
    21.  
    22.         CombatMessage lCombatMessage = rMessage as CombatMessage;
    23.         if (lCombatMessage != null && lCombatMessage.Defender != mActorCore.gameObject)
    24.         {
    25.             return false;
    26.         }
    27.  
    28.         mMessage = lCombatMessage;
    29.  
    30.         return true;
    31.     }
    32.  
    33.     /// <summary>
    34.     /// Called when the reactor is first activated
    35.     /// </summary>
    36.     /// <returns>Determines if other reactors should process.</returns>
    37.     public override bool Activate()
    38.     {
    39.         if (Random.value < BlockChance)
    40.         {
    41.             if (mMotionController.CurrentForm == 500)
    42.             {
    43.                 this.mMotionController.ActivateMotion("Dodge");
    44.             }
    45.             else
    46.             {
    47.                 this.mMotionController.ActivateMotion("Parry");
    48.             }
    49.         }
    50.  
    51.         // Disable the reactor
    52.         Deactivate();
    53.  
    54.         // Allow other reactors to continue
    55.         return true;
    56.     }
    Now the code here does work but not as intended. When a message enters the reactor it is already too late and even if my NPC dodge it will still look like he is being hit.

    Therefore i need some indication earlier even before the swing animation of my player has started. However, i am not quite sure how to do this. I can think of a lot of hacky ways but I was hoping there was something like this in the ootii system instead of me making something custom.

    Also i can't be the first to have this issue :D

    Can anyone help me?
     
  18. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    Did you try adding a reactor to the Pre attack Message being sent by the Motion Controller?

    More information can be found by watching this video by Tim. At around the 11 min mark he talks about doing stuff pre attack.

     
  19. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    So yes this is exactly one im using there are two issues with this approach:

    1. The message is related to the attacker (in this case our player) and not actually the defender (our NPC) Which means that we can't directly conclude that the PC is going to attack that single NPC or if the attack would hit another NPC
    2. Even if we could do (1) then we wouldn't have time to actually run the animation for a dodge. As this happens when the attack motion already starts and we would have to make the motion controller of the NPC run the dodge motion script. This will cause that the NPC is too slow to actually do the dodge and it will look odd.
     
  20. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    Tryz likes this.
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    What is the motion you are calling that runs the sit animation? Did you create your own sit motion?
     
  22. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey @Tryz

    I have a question about the draw power on the bow core.

    So on the bow core, there is a min and max draw power. after a lot of testing, this basically controls how far and fast the bow will be able to shoot.

    So in my scene, I have some archers on the wall that would need to barrage down on the battlefield. However, here lies a problem.


    I've set a transform in my scene which hovers over and followers a character around. The archers will look at that transform and shoot towards it. However due to the way the draw power works they will always overshoot or undershoot the target by quite a lot.

    My idea was to change the draw power at runtime but i am not sure that this is the best option.

    Could I get some advice on this matter?

    PS Sorry for the many questions lately I know I'm a pain in the arse :D
     
  23. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Orbit Rig that comes with the MC keeps it's it pitch and yaw internal and adjust based on that.

    Ill have to look over the weekend, but I don't think you can force a yaw or pitch. The Orbit Rig and the Fixed Rig are examples of how you can use other cameras with this character controller. You may need to customize your own camera to get features you want.
     
  24. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    I would really appreciate if you could help me out. Orbit rig is exactly what I need. What i can't figure out is why it always overrides any changes(even those that are done after lateupdate)
     
  25. bighale

    bighale

    Joined:
    Nov 15, 2016
    Posts:
    2
    Hello all so I need some help I'm still learning C# and I need help with the easy input I was wondering did anyone have an example of how to implement the spell casting and shooter packs into the easy input using keyboard and xbox controller. Or could you point me in the right direction I've gone threw the documentation and video but I don't see actual examples of how to do that.

    Thank you
    Matt
     
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey Matt,

    In the documentation I show you can set the action alias to cast a spell on the Basic Spell Casting inspector. The tricky part is which spell gets cast. So, I provide the code in the documentation and in the example spell bar code.

    Basically, set the Parameter property on the Basic Spell Casting motion.

    I hope that helps. If you are still lost, I'll do another example this weekend.
     
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I'll look at the code this weekend and give you an example.
     
  28. Tryz

    Tryz

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

    The Draw Power is based on the min value and then ramps to the max value when the player over-draws the bow. Since NPCs don't over-draw, you would always get the min value.

    I think the biggest thing you are seeing is the arrow reacting to the shot angle. I'm using Unity physics for the arrow trajectory. So, it will arc. A slight change in the spine or left arm will change that trajectory.

    If you go into the Arrow prefab, you could disable gravity on the RigidBody. Then the arrow will shoot straight. I'm thinking that may be better in this case.

    Changing the left arm like you are the spine would give you more aim too.

    Either way, the power and direction should be consistent.

    I hope that helps.
     
  29. bighale

    bighale

    Joined:
    Nov 15, 2016
    Posts:
    2
    Thank you Tim

    I will try and see if I can get it to work
     
    Tryz likes this.
  30. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    Thank you!
     
  31. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Orbit Rig wasn't really meant for the SetTargetForward() to stick, but by changing code a bit you can make it work.

    Go into OrbitRig.cs and at line 342, change it from this:

    Code (CSharp):
    1. mFrameLockForward = false;
    to this:
    Code (CSharp):
    1. //mFrameLockForward = false;
    2.  
    3. lNewAnchorPosition = _Anchor.position + (_Anchor.rotation * _AnchorOffset);
    4. lNewCameraPosition = lNewAnchorPosition - (-mToCameraDirection * _Radius);
    5. lNewCameraRotation = Quaternion.LookRotation(-mToCameraDirection, _Anchor.up);
    With that, when you call SetTargetForward(...), the direction will stick until you call ClearTargetForward().

    Here's an example script that I put on the OrbitRig GameObject to test:
    Code (CSharp):
    1. using UnityEngine;
    2. using com.ootii.Cameras;
    3.  
    4. public class StanislovdolGUI : MonoBehaviour
    5. {
    6.     void OnGUI()
    7.     {
    8.         // This will force the yaw/pitch of the camera rig, but doesn't make it stick.
    9.         if (GUI.Button(new Rect(10f, 10f, 100f, 20f), "Force Yaw"))
    10.         {
    11.             OrbitRig lRig = gameObject.GetComponent<OrbitRig>();
    12.             lRig.SetTargetYawPitch(90f, 0f, 0f, false);
    13.         }
    14.  
    15.         // This forces the direction of the camera rig and sill stick.
    16.         if (GUI.Button(new Rect(10f, 35f, 100f, 20f), "Force Direction"))
    17.         {
    18.             OrbitRig lRig = gameObject.GetComponent<OrbitRig>();
    19.             lRig.SetTargetForward(Vector3.right, 0f, false);
    20.         }
    21.  
    22.         // This clears teh forced directon of the camera rig.
    23.         if (GUI.Button(new Rect(10f, 60f, 100f, 20f), "Clear Direction"))
    24.         {
    25.             OrbitRig lRig = gameObject.GetComponent<OrbitRig>();
    26.             lRig.ClearTargetForward();
    27.         }
    28.     }
    29. }
    I hope that helps,
    Tim
     
  32. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey all :)

    I have a problem with my characters that i have been unable to fix.

    For some reason when a character dies he gets stuck in an incorrect motion:

    upload_2019-7-15_18-15-11.png

    As you can see from this image the character is dead and the death reactor has disabled both the motion controller and the actor controller.

    However as you can see the character is still standing up.

    Upon inspecting his animator you get this:

    upload_2019-7-15_18-16-16.png

    As you can see he is stuck in his SwordShield damage motion but looking at his L0MotionPhase he should be in the dead motion.

    Normally when things like this happens it is usually because the animator was unable to find a motion that fits the parameter (which is usually caused because you forgot to add the parameters)

    However this is not the case with my build:

    Here is the death 0

    upload_2019-7-15_18-18-48.png

    And here is the death 180:

    upload_2019-7-15_18-19-2.png

    So what could cause this problem?
     
  33. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    @Tryz

    Hi Tim, Having played around with different AI systems, I have started to code my own and have gone back and studied your Ripper series on YouTube and wondered if you ever shared that code or have plans to share it or are willing to share it or are you still holding it close for a future asset release or or or. Just wondering.
     
  34. Tryz

    Tryz

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

    One thing I see is that the L0MotionParameter condition for Sword & Shield Death requires a value > -100 and < 100. However, in the animator parameters, the L0MotionParameter value is 123. Since it isn't < 100, the death transition doesn't fire.

    Do you know where the 123 is coming from? I'm looking and do see it in my basic flow.

    BTW...
    Thanks for the images, they really help!
     
  35. Tryz

    Tryz

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

    Unfortunately, work is keeping me super busy and I probably won't get to finish that for a while. I wouldn't call any of that 'production ready' and really don't have plans on sharing it yet.

    I hope you understand. ;)
     
  36. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    I have always wondered why there is this range? what if i just remove the Parameter
     
  37. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I remembered this morning that it's the angle of the incoming attack.

    Does the second transition exist that covers after 100 degrees?

    Is the animation miss consistent? Go ahead and email tim@ootii.com
     
  38. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    I found the issue!

    Apparently for some reason what was suppose to be the L0MotionForm was set to L0MotionPhase (which made it double)

    After changing this it the issue seems to be fixed.
     
    Tryz likes this.
  39. stanislavdol

    stanislavdol

    Joined:
    Aug 3, 2013
    Posts:
    282
    Thanks a lot!
    When using this dynamically, I sometimes see camera changing direction for a fraction of a second(most likely for 1 frame) then going back to a desired rotation.(it's like a flash showing a scene from another angle).
    In a remote player where actor/motion controllers are disabled this doesn't happen.

    SetTargetForward() enforces a new camera direction, but when I call ClearTargetForward() is it supposed to go back to it's previous direction or continue from the new one?
     
    Last edited: Jul 19, 2019
  40. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I can't think of why it would change direction. The code I added for you is using Unity's standard Quaternion.LookRotation() at line 346 of OrbitRig.cs. I'm not seeing anything odd in my tests. If that's not working for you, I'd say that's just not a feature of the Orbit Rig that I provide in the MC.

    When ClearTargetForward() is called, it doesn't remember the old position. It would simply stay with the new position.
     
  41. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    773
    To celebrate the 50th anniversary of the first moon landing, I decided about a week ago that before the week was out, I'd put a man on the moon. I almost didn't make it, but with an hour or so to spare, here's my homage to NASA and the space race. As usual, I couldn't have done it without Unity, Gaia for the moonscape, and Ootii for letting me take those steps and leaps,..

     
    TeagansDad, hopeful, rubble1 and 2 others like this.
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Happy Moon Day! :D
     
  43. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    Hi, I'm having trouble understanding the Activate Motion action for Behavior Designer. It's significantly different than the Node Canvas action and there's no documentation. I figured out it's activated by name, layer index is also self explanatory. What is Completion Index? And what do I need to put into exit state, exit time? Tried putting Idle there (after naming it) but no effect, the character just freezes up once it goes through the animation. Exit time seems to have no effect either.
     
  44. Grendelbiter

    Grendelbiter

    Joined:
    Oct 14, 2016
    Posts:
    123
    So, is this asset dead?
     
  45. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    @Tryz

    No, definitely not. Tim got a new job in Japan and answers on the weekends. Plus the unity forums do not always notify of updates. If Tim doesn’t answer soon I will look later tonight.
     
    Wolfmoss and Tryz like this.
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    No. I'm sure you saw my post directly above yours. ;)

    As I mention on the Vault where I provide the Behavior Designer integration (for free), I'll help when I can. So, it may take a couple of days for a reply.

    There isn't documentation for some of these free integrations, but I try to make things self explanatory. Behavior Designer is trickier because they changed how their UI renders (a while back). You'll have to look at the code.

    Check out ActivateMotion.cs and the comments. At line 246, I commented out the Behavior Designer GUI code which showed the Completion Index drop-down because the Behavior Designer GUI changed. You can try uncommenting that and resolving any issues.

    Typically motions end themselves based on the end of an animation or experience. So, activating the Jump motion would automatically end when the jump ends.

    Behavior Designer's OnUpdate() method uses the Completion Index, but that was really for movement. Use the "Deactivate Motion" node if you want to force a motion to deactivate (and it doesn't do it automatically... like jump).

    You're welcome to beef up the custom nodes I created. I fully expect that people will need to customize them for their custom games. Hopefully what I provide is a good example to start from.
     
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thank you! I super appreciate you (and others) willing to help and understanding my job situation.
     
    KeithBrown likes this.
  48. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Tryz, TeagansDad and hopeful like this.
  49. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Tryz and christougher like this.
  50. Hazardous1

    Hazardous1

    Joined:
    Nov 17, 2018
    Posts:
    3
    Having an issue, when I jump the players foot gets stuck in the ground and the jump animation triggers with a stutter, but doesn't actually jump upward. Probably something I missed.