Search Unity

Motion Controller

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

  1. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    @KeithBrown Thanks that did help. Shift and F are now working in the demo scenes. However the _QuickStart scene is still not responsive.
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    @antsonthetree How are using using the "_QuickStart Start Demo Template" scene?

    You'll want to setup your character per the User Guide. For example, I did this:
    1. Started a new Unity 2020.2.2f1 project
    2. Imported the Motion Controller
    3. Opened "__Quick Start Demo Tutorial"
    4. Added my Proto character
    5. Added the Motion Controller
    6. Pressed "Setup Input Entries" on MC
    7. Pressed "Adventure Style" movement style on MC
    With that, I was able to walk, run, jump, etc.

    Pressing the "Adventure Style" sets up the:
    1. Input Source
    2. Camera Rig
    3. Actor Controller (basic settings)
    4. Motion Controller (basic settings)

    The _QuickStart scene is just an environment you can tweak to test different aspects of the Motion Controller and Motion Packs. Start with the specific demo scenes in "_Demos > Motion Controller > Scenes" as those show specific abilities.

    I hope that helps,
    Tim
     
    TeagansDad likes this.
  3. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Also, if you use the Character Builder, it will set up the camera controller and input source in the scene and ensure all necessary input aliases are created. I exclusively use the Character Builder and the _Quick Start scene whenever I'm working on anything, so I can vouch that it works. :)

    If you use the CB, then don't use the movement style buttons on the Basic view of the Motion Controller, or it will overwrite what the CB set up for you.

    I suspect that you were missing the required input entries.
     
    Tryz likes this.
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    @TeagansDad is the Character Builder guru! Listen to him. :)
     
    TeagansDad likes this.
  5. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    @Tryz Thanks guys. I assumed it was just a start and run scene like the others. I didn't realize it was more of a testing lab / setup thing. Appreciate the clarifications!
     
  6. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    I do have a follow up question: I notice in the demo scenes for MotionController that each of the PlayerBots has a Rigidbody attached. However it does not look like it is required or even used. I deleted it from a couple of the bots and the controller still works fine. Am I missing a step or why are they there? I'd prefer my characters to not have them (rigidbodies) if possible.
     
  7. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    It's there so that they can interact with other rigidbodies (for example, knocking over objects). If you don't want that, then it's safe to remove.
     
    antsonthetree likes this.
  8. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    Hello - Thanks for your help so far. Now I have another issue that hopefully has an easy solution.

    I am trying to implement gravity on a very small planet. For now I'm using a standard sphere scaled to 30,30,30 along with the example player capsule and Actor Controller. Here are the steps I followed:

    1. I created a simple monobehavior that takes a normalized vector (GV) from the actor's position to the center of the sphere and in the FixedUpdate I set the AC.Gravity = -GV * 9.8. This worked except the actor did not orient with the gravity vector.

    2. In ActorController.cs I changed the alignment code at lines 2141 and 2147 to use mWorldup instead of Vector3.up. This fixed the alignment issue and now I can walk around my planet. Running and jumping. Yay.

    Here is where my problem happens. I built a small ramp on the planet surface with a cube, ran up it, and jumped off. When I land back on the planet I keep sliding forwards. Sometimes I even slide backwards. If there is another ramp in front of me after I land, I will usually slide up the ramp. I do have Sliding turned off in the AC settings. I suspect this is related to the accumulated velocity vectors but I haven't been able to find out exactly where the issue is.

    I unfortunately cannot use the Relative Gravity and Align to Surface options as this makes the actor align to the surface normal and not the gravity direction. My surface will not always be a regular sphere. Eventually it will have irregular shaped features and I want my actor to always be oriented with gravity regardless of the surface he is on.

    Hope someone can help. I can put together an example project if necessary.

    Thanks
     
    Last edited: Sep 14, 2021
  9. Jayiel

    Jayiel

    Joined:
    Nov 1, 2018
    Posts:
    2
    We started working on getting in the ootii melee combat system and were also working separate from scratch on tree chopping as well as harvesting and mining. One of our programmers says we do not have to build them from scratch, as the ootii system can be used for chopping trees and rocks (aka mining) and harvesting food items with tools. They say the ottii system does not care what the player is doing as far as combat, harvesting gardening or trading items as long as we have the appropriate animations and tools / weapons and set it up correctly.

    Is this correct? Would we just set up each tree prefab or rock prefab similar to the NPC enemies (to take damage and die) and the payer use an ax, pick ax and hoe in place of a sword. If this is true, then we could also use the ootii system for non-combat interaction with NPCs. The player could then give an item to an NPC the same as using a weapon to do damage to an NPC. I did not see any videos on YouTube showing this concept of how to use it like this for non-combat tasks. If we can use the add-ons for more than combat we will also buy the oottii Shooter Motion Pack add-on for doing ranged healing in a Sci-Fi medic scene we will be working on next. (like a Star Trek Phaser only it heals instead of damaging)

    ALSO: We did get the swimming animations swapped out.
    We have it working perfectly in the Suimono Ocean and R.A.M. Lakes, but it will not swim in the R.A.M. River so we are removing the R.A.M. River and using a shallow GeNa Pro River the player can wade across.

    ootii items on our buy list:
    ootii Mounts
    ootii Shooter Motion Pack
    ootii Dispatcher
    ootii Easy Input
    ootii Debug Logger

    I am now interested in seeing just how much we can do with the ootii asset tools.
    We already have:
    ootii Third Person Motion Controller
    ootii Camera Controller
    ootii Swimming Motion Pack
    ootii Spell Casting Motion Pack
    ootii Archery Motion Pack
    ootii Sword & Shield Motion Pack
     
  10. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    @Jayiel Ootii's system will allow you to play any animation without writing any code.



    It will also allow you to write custom motions that will let you do anything that you want. You can use the included motions as guides to do what you want.



    There is also the motion builder's guide. https://ootii.com/wp-content/uploads/MCMotionBuilder.pdf

    If you place a component that implements IDamagable on any object, it will take damage from the ootii combat system. This post talks about it. https://forum.unity.com/threads/motion-controller.229900/page-121#post-3890944

    If you search for IDamageable in the Ootii codebase you can see how Ootii's components will get that component from a gameobject and call its interface members.
     
    Last edited: Feb 11, 2021
    LNMRae likes this.
  11. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I was attempting to improve upon the sword core and add some functionality by adding the attack profiles and some weapon trails to an AdvancedSwordCore when I ran across some issues. It made sense to move the weapon trail functionality to an AdvancedWeaponCore class and have my AdvancedSwordCore class inherit from that instead. Unfortunately, BasicMeleeAttack is trying to reference a SwordCore type which is no longer in my class chain. I believe my only alternative at this time is to either modify the WeaponCore and/or SwordCore OR create an AdvancedMeleeAttack motion which is identical at this point but references my classes instead.
     
    Last edited: Feb 16, 2021
  12. claudius_I

    claudius_I

    Joined:
    May 28, 2017
    Posts:
    254
    Hi. I have a problem.

    my idlePose is very long (2 second) and when i trigger a simple animation, this wait to finish the idle Pose Animation. there is a wayto i can a fix that?

    Thanks
     
  13. limpin_jezus

    limpin_jezus

    Joined:
    Nov 20, 2015
    Posts:
    18
    I am using the message dispatcher to send a message to the Motion Controller to update a motion parameter thus:
    in start...
    #if USE_MESSAGE_DISPATCHER || OOTII_MD

    MessageDispatcher.AddListener("StatUpdate", HandleStatUpdate, false);

    #endif
    ...

    private void HandleStatUpdate(IMessage incomingMessage)
    {
    var stat = (CombatNode.NODE_STATS) incomingMessage.Data;

    if (stat._name != "MOVE_SPEED")
    {
    incomingMessage.IsHandled = true;
    return;
    }

    var walkRunPivotV2Motion = this.GetMotion(0, typeof(WalkRunPivot_v2)) as WalkRunPivot_v2;

    walkRunPivotV2Motion.RunSpeed = stat.curValue;
    incomingMessage.IsHandled = true;
    }


    This works perfectly, EXCEPT when the character is first loaded. It changes the walkRunPivotV2Motion.RunSpeed parameter, as evident by logging the value to the console after the change, however, looking at the Inspector, the motion Run Speed value is not modified.

    I can't seem to put my finger on what is further modifying the motion parameter; perhaps an initialization? At any rate, if I delay the message via the sender, by a few milliseconds it resolves the issue, but that's unstable at best. Any suggestion for what I can check in my HandleStatUpdate method to ensure the motion is good to go before I modify it?
     
  14. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    228
    For the spell and the combat system, I saw in your video that you always click on an icon to cast something.
    Can the spells be keybinded instead, and does your asset "Easy Input" cover that?

    Edit: any Ultimate Inventory system integration? :)
    Edit2: One last pre-buy question!
    If I use Ooti and all the modules for the combat system, can integrate it with Behaviour Designer without too much effort?
    All I need is a function that tell the AI to call X attack/spell, and have the movement/targeting controlled by Behabiour Designer
     
    Last edited: Feb 28, 2021
  15. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    74
    Hey Tryz,

    I have the same issue as here (though the spell editor seems usable now): https://forum.unity.com/threads/motion-controller.229900/page-140#post-5999531

    Have you gotten anywhere with a solution? I suspect more and more people have high res screens with dpi scaling activated. I also want to keep it activated in Unity, otherwise everything will get blurry. I don't have this issue with any other assets (and I have quite many), the solution must be quite straight forward. Unfortunately the ooti component editors all look broken without the icons...
     
  16. CATByte_Studio

    CATByte_Studio

    Joined:
    Jun 4, 2018
    Posts:
    8
    Good day everyone,

    I am using Saljas' mobile input (https://forum.unity.com/posts/5323017/) and its working great for all the actions like Sneak, Run, Cover, Jump etc. except for switching weapons, stored in the BasicInventory script included with ootii.

    Switching weapons works fine with the keyboard.

    To get it working with virtual buttons; I attached the MobileInputSource script to the Input source, and I attached the Input Source to the BasicInventory script.

    Saljas' demo includes a ButtonHandler script which I use to send the ActionAlias to the InputSource to be read and executed.

    However, the BasicInventory script does not read the ActionAliases the ButtonHandler script is sending (in this case- Equip Pistol or Equip Rifle), whenever the Virtual Button its attached to; is pressed.

    Please help, any advice would be appreciated, thanks :)

    See screenshots below...

    mobile input switching weapons1.png
    mobile input switching weapons2.png
    mobile input switching weapons3.png
     
  17. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845

    Not sure which version of Unity or MC you are using... either way, be sure to debug when the button is pressed for which ever is not working..

    The basic inventory, you may need to edit, for any sort of mobile inputs, in the past I had to do this, its been a bit since I looked at Tim's basic inventory, so he may have added since I used it.. follow along with this.
     
  18. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Sorry for the late response.

    You are correct; you'll need to modify one of those classes or create your own attack motion. It would probably be better if the BasicMeleeAttack motion referenced an ISwordCore interface instead of the SwordCore implementation.

    I would probably offload the weapon trails to a separate component, rather than including that functionality in a WeaponCore-derived class. I've already experimented with moving all of the sound effects out of SwordCore into a separate component, abstracted behind an IWeaponAudioCore interface (so you could have different components implementing IWeaponAudioCore for different audio solutions, such as WeaponUnityAudioCore or WeaponMasterAudioCore). This was working pretty well, so I would use the same approach for weapon trails and other visual effects.

    I'm thinking from the perspective of extending the ootii framework though; if you're adding visual weapon effects purely for your own use, then the layer of abstraction might be more hassle than it's worth.
     
  19. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Did you manage to resolve this issue?
     
  20. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    The component which manages the spells (SpellInventory) simply holds them in a List. The demo scene assigns the first 5 spells in that list to the on-screen icons. You would need to write up a bit of script to bind specific keys to those SpellInventory slots.

    Not as of yet (nor has anything been started, to the best of my knowledge). I was thinking of picking up the asset, but I've been mostly away from Unity for the past few months and haven't gotten around to buying it yet.

    There is an integration package for BD on the Motion Vault. It's more or less a quick port of the same integration package available for NodeCanvas. The tasks cover movement, attacks, etc.
     
    mick129 likes this.
  21. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    I don't think that Tim has gotten anywhere with it. I know I certainly haven't.

    It probably is a straightforward solution... unfortunately, I still have no idea what that solution is. It has to be something in the shared Framework code library that draws the custom Editor GUI.

    It's on my to-do list when I'm able to get back to regularly working with Unity again.
     
    Falondrian likes this.
  22. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    BasicInventory only handles the Inventory Toggle and Inventory Switch aliases. It's also hard-coded to handle the numeric keys (1 to 0), each corresponding to the position within the Items collection on BasicInventory.

    The various input aliases used by the Motion Packs (Equip Sword = 1, Equip Bow = 2, etc) are handled by the BasicItemEquip and BasicItemStore motions, rather than on the inventory component (so that the motion pack isn't dependent on having an inventory). This simple approach clearly doesn't work if you have multiple weapons set up on a character.

    BasicInventory checks GetKeyDown() when testing for numeric key input, so you can't actually bind anything to that. You would need to check the input aliases for the numeric keys and initiate the equip logic on BasicInventory externally. Either that, or inherit from BasicInventory and have it handle your input aliases instead of checking GetKeyDown().
     
    CATByte_Studio likes this.
  23. CATByte_Studio

    CATByte_Studio

    Joined:
    Jun 4, 2018
    Posts:
    8
    Thanks man, I took your suggestion above and it worked out nicely.
    It was staring me in the face all along, i knew it. lol
    The development can continue finally!


    Much thanks again!;)
     
    TeagansDad likes this.
  24. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    You're welcome! Glad I could help.
     
  25. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Just wanted to let you know that I've figured this out!

    The code for drawing the custom inspectors loads a texture and assigns it to a GUIStyle.normal.background for the corresponding style (for the title box, ootii icon, etc). The property normal is a GUIStyleState. For high resolution screens, the background images used by the state need to be specified in the scaledBackgrounds property, and such images should be exactly twice the resolution of the image specified in background.

    I don't have a high DPI display, but I can reproduce the issue if I set my display scaling to 125% or greater. I did a quick fix and got the ootii Icon and TitleBox GUIStyles drawing properly again:

    upload_2021-4-13_18-48-6.png

    However, there are a lot of Editor GUIStyles to fix up, so I don't recommend fixing it yourself (unless you absolutely need to). I'll do an extensive sweep through all of the custom inspectors this week and ensure that I've added scaledBackgrounds where necessary (and I also need to create double-resolution images for those as well).

    I'll post again here when I'm done. Sorry for the long wait in getting this fixed.
     
  26. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    I have fixed the high DPI monitor display issues with all of the ootii custom inspectors. Fixed the Spell Editor too, with the caveat that if you move the Spell Editor window between high and low DPI screens, the node panels on the left don't draw properly until you restart Unity. Not sure how to fix that, but I'll keep looking into it.

    Not sure when we'll be able to push out a new version to the Asset Store, but in the meantime, PM me if you need the fixes. In addition to the universal fixes in Framework_v1 files, I had to modify some files specific to Camera Controller, Bone Controller, and the Spellcasting Motion Pack, so let me know which of those you need.
     
    dmenefee likes this.
  27. Invirtuo

    Invirtuo

    Joined:
    Nov 30, 2016
    Posts:
    14
    Hi,

    I would like to know how to trigger your Basic Interaction module other than using the INTERACT alias. It's for using on an NPC. Is it possible to call it manually by script? I have look at the code but I can`t find a way to call it by another script.Can you give me a quick example?
     
  28. unity_zI0bplWwlBVpmA

    unity_zI0bplWwlBVpmA

    Joined:
    Feb 22, 2020
    Posts:
    2
    aaaaaaaa.JPG Hello! So i followed the videos and i am sure 100% that i did everything right for the archery motion pack setup
     
  29. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Just to get the low-hanging fruit out of the way, can you verify that you have copied the Mixamo animations to the correct folder?

    Assets/ooii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo

    upload_2021-4-22_16-5-44.png

    Also, please confirm that you have unzipped the contents of Extras/AnimationMeta.zip to this same folder (after letting Unity import the Mixamo animation files).

    The inspector for the Archery Motion Pack checks for the file Assets/ootii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo/standing idle 01.fbx -- since you're seeing that message, it means that the file is not present in that directory.
     
  30. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Sure thing! This sample code assumes that it is a method on a MonoBehaviour and that you already have a reference to the NPC's MotionController component (as mMotionController). The GameObject being passed into the method is the object that the NPC will interact with, and this script assumes that there is an InteractableCore component on that object.

    Code (CSharp):
    1. public void Interact(GameObject testObject)
    2.     {
    3.         // Get a reference to the BasicInteraction motion on the NPC
    4.         var basicInteraction = mMotionController.GetMotion<BasicInteraction>();
    5.         if (basicInteraction == null)  { return; }
    6.  
    7.         // Check if the GameObject to be interacted with has an InteractableCore component
    8.         var interactableCore = testObject.GetComponent<IInteractableCore>();
    9.         if (interactableCore != null)
    10.         {
    11.             // Assign a reference to the IInteractableCore to the motion
    12.             basicInteraction.InteractableCore = interactableCore;
    13.             basicInteraction.ActiveForm = interactableCore.Form;
    14.  
    15.             // We don't want to keep a prior reference to a GameObject if we have an IInteractableCore reference
    16.             basicInteraction.Interactable = null;
    17.  
    18.             // If the IInteractableCore is configured to adjust the character's position, begin moving the NPC to the correct
    19.             // transform. We won't actually the BasicInteraction motion here; MoveToTargetInternal will activate the motion
    20.             // when the NPC has reached the target transform
    21.             if (interactableCore.ForcePosition || interactableCore.ForceRotation)
    22.             {
    23.                 mMotionController.StartCoroutine(basicInteraction.MoveToTargetInternal(interactableCore));
    24.             }
    25.             else
    26.             {
    27.                 mMotionController.ActivateMotion(basicInteraction);
    28.             }
    29.         }
    30.     }
    Disclaimer: I haven't tested this code, so I can't guarantee that it will work straight out of the box. I looked at the activation process in BasicInteraction when using an input alias and pulled out all of the bits that should be necessary to have an NPC perform an interaction via scripting.

    Essentially:
    1. Get a reference to the GameObject with the InteractableCore component
    2. Get a reference to the NPC's BasicInteraction motion
    3. Assign the object reference and Motion Form to the motion
    4. Either start moving the character to the target transform OR activate the BasicInteraction motion manually
     
    Invirtuo likes this.
  31. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey i would have posted this on the new forum but I am not reciving my mail after registering so now il post it here.

    Is there a way from code to run the Equip of another weapon and is there a property I can set so that no animation plays.

    The reason I am asking is that I have a Spear weapon that can be thrown and once the player has thrown the spear he should be using his hands to attack (changing the weapon type to melee) Then once the spear returns I want to requip the spear but this time using a different animation.

    What is the best way of achieving this? :)
     
  32. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    Quick question I'm a little confused about how Sword Core works.

    So my understanding is that putting Basic Attack Profiles on the sword makes sense, that way I could have 100 weapons with 100 different attack profiles without managing all that on the motioncontroller. However, what seems to happen is that if I do the default pack set-up that works as expected, but if I add my own custom Basic Melee Attack script it adds a ton of Attack Profiles to the motion controller and if I remove them they aren't added when the sword is equipped, am I misunderstanding something here?
     
  33. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Yes, that's exactly how I intended it to work. In order to avoid breaking backwards compatibility and forcing people to use the Attack Profiles, I had to design it such that it worked outside of the original, default setup for the Sword and Shield Motion Pack (SSMP).

    An AttackStyle represents a specific attack animation and includes all of the properties necessary to perform that attack, damage modifiers, etc. This class is part of the original SSMP code.

    An AttackProfile represents a set of AttackStyles that are associated with a specific type of weapon (or way to hold a weapon, as you could have different AttackProfiles for attacking with a sword with a two-handed grip vs with a shield in the other hand). This was a later addition that I made to make it easier to manage AttackStyles when a character can switch between multiple weapon types. An AttackProfile is a ScriptableObject, so these sets of AttackStyles are defined at design time and can be easily re-used.

    The BasicMeleeAttack motion has no knowledge of what an AttackProfile is. It only knows about AttackStyles.

    The BasicMeleeAttack motion has an Editor method named AttackStyleListReset(), which will add all of the default AttackStyles from SSMP to the motion. It is called if you press the Reset button in that motion's inspector, and also by default when you run the motion pack setup. There is a checkbox to Use Attack Profiles, which skips this step.

    The SSMP setup script should be adding a Basic Attack Profiles Reactor to the character's Actor Core component (even if Use Attack Profiles is not checked):

    upload_2021-4-27_10-58-16.png

    This reactor is the piece that does all of the work at runtime It listens for the MSG_INVENTORY_WEAPON_SET_EQUIPPED message sent by Basic Inventory when a weapon set has been equipped. Upon receiving the message, it gets a reference to the equipped weapon via the Combatant.PrimaryWeapon property, clears the current Attack Styles on the Basic Melee Attack motion, then copies the Attack Styles from the Basic Attack Profiles component to the attack motion.

    Likewise, the reactor listens for the MSG_INVENTORY_WEAPON_SET_STORED message and clears the list of Attack Styles on the motion when a weapon set is stored.

    If I were designing the system from scratch rather than as a modular extension, I would have made it a bit more straightforward. ;)

    Whether you set up a character with the original Motion Pack setup inspectors or with the Character Wizard, the Basic Attack Profile Reactor should be getting added to the character.

    So if you're using Attack Profiles, then you'll want the list of Attack Styles on the Basic Melee Attack motion to be empty at design time.
     
  34. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    If you leave the "Equip Motion" field blank on the BasicInventoryItem inspector, then BasicInventory should just instantiate the weapon without running the motion. You could clear that field on the item, equip it, then restore it. A but kludgey but it should work.

    You'd probably want to represent each of Unarmed (hands), Spear Melee, and Spear Thrown as different Weapon Sets, as each would use their own Motion Form. You'd then need a custom component (or maybe a Reactor, which would be a bit more lightweight) to listen for specific messages and switch the current equipped Weapon Set between those three.

    That's where I'd start anyway. I'm probably overlooking something with that broad overview though.
     
  35. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    Great! Thanks for the detailed response, it's appreciated.

    I'm also having an issue with extending the combo system, I wrote this question on the forum:

    So I have a custom controller (copied) and a custom BasicMeleeAttack (copied).

    All I'm trying to do is add a third combo element to the basic attack, I've adjusted the state machine so that Back Slash links to Spin Slash with a motion form 102, I've adjusted the Attack Style to include it and I've tried removing End Chain event from Back Slash animation and even commenting out the End Chain event in the code but I just can't get it to follow throw with the third attack. Where am I going wrong here? What if I wanted to add a 10 anim combo?
     

    Attached Files:

  36. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    You're welcome!

    Your animator controller looks correct. You will need the BeginChain and EndChain animation events on the animation clips for it to work correctly, as those define the window of time during which further input will continue the combo.

    upload_2021-4-27_17-16-18.png

    What you may be missing is the link between Back Slash and Spin Slash. In the inspector panel for Back Slash, you need to specify the index of Spin Slash in the Next Attack Style field on Back Slash (in the default setup, its index is 2). I can't tell if you have it set, as it's cut off in your screenshot.

    upload_2021-4-27_17-10-3.png


    If you're using Attack Profiles, then this part is simpler, as you don't need to specify the Next Attack Style. Checking Is Attack Chain indicates that this profile's Attack Styles are all part of a combo chain and when the reactor copies the list of Attack Styles to the motion, it will automatically assign the correct index for the Next Attack Style.

    upload_2021-4-27_17-13-6.png

    I'll duplicate this response over on the forum.
     
  37. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    That was immensely helpful!

    So I was actually setting things up correctly but the problem was in duplicating the BasicMeleeAttack and renaming it to a new script, that was breaking everything as it appears the S&S stuff references that class specifically I don't know if I would've ever figured that out.

    This tool is so powerful, but it is pretty complicated it's tough to work through some of the issues on your own.

    Another question (I have hundreds!) why can't I just interrupt the first motion form by spamming the attack button? There's no "can be interrupted" toggle in the Attack Style is there a check for that somewhere else? I actually want the player to be able to spam and reset the first attack because it can feel a bit unresponsive at the end of that initial attack not being able to start another straight away.
     
  38. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    While I'm asking questions, is there any support for/plans related to characters syncing with one another, so say an execution attack with the player and enemy in sync together?
     
  39. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Glad I could help!

    If your custom motion inherits from BasicMeleeAttack, then the other SSMP scripts should be able to reference it. What behaviour are you customizing in it?

    There is an IsInterruptible property on Attack Style, and an mIsInterrupted field in BasicMeleeAttack -- but the naming is a bit confusing, as they refer to an attack being blocked (as opposed to canceled). There isn't anything built in to the existing system to do what you're looking for.

    I agree about it feeling unresponsive, and somewhere around here I have improved versions of BasicDodge and BasicDamaged that are able to transition out of the animation before it ends. The general approach I took was to add an animation event at the frame of the animation where I wanted it to be able to transition out ("EndDamage" or "ExitDodge" or something like that). Then I check for that in the motion's OnMessageReceived() method. For the attack animations, you might place such an event a few frames after the "endchain" event. If the Attack input wasn't pressed in time to continue the chain, then you'd check for the Attack input (in Update()) during a certain time window afterwards; if it is pressed, then set a class-level boolean. In OnMessageReceived(), you'd check that boolean value and for an "EndAttack" message, then begin exiting out of the motion early.

    You would leverage the CombatMessage to accomplish this. The documentation for the Sword and Shield Motion Pack goes into some detail as to how the CombatMessage is built up as it is passed back and forth between the attacker and the defender. You might use a custom ReactorAction to handle these. On the defender, you could check the CombatMessage for what Attack Style is being defended against and activate a specific motion in response to that.
     
  40. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    That makes sense, but how would I actually achieve that, setting up the animation event that's all fine, but how do I interrupt the current motion (in which method of which class) and tell it to exit the motion?

    Also the combat message stuff, yep that's what I intend to do but I more meant the actual physical syncing of the animators together, where their transforms end up so that when they each play their respective animations they align, does that make sense?
     
  41. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I'm having trouble setting up left hand IK to properly grip the stock of a rifle when using the Shooter Pack. I tried the Left Hand IK instructions from https://ootii.com/knowledge-base/tips-and-tricks/, but they don't provide enough control. Most other IK solutions I've seen assume that the rifle is always present. I'm not sure how to get them to reference a rifle when it gets instantiated by the SHMP/Inventory system...

    Edit: Figured it out. Since Unity's OnAnimatorIK() callback needs to be on the player to access its animator, and can't be told ahead of time what the IK target on the rifle will be, I made 2 scripts. The first goes on the player, and does the actual IK adjustments.

    Code (CSharp):
    1. // This is the main IK script. It goes on the object whose animator will be used - usually the player
    2.  
    3. using UnityEngine;
    4. using System;
    5. using System.Collections;
    6.  
    7. [RequireComponent(typeof(Animator))]
    8.  
    9. public class RifleSupportIK : MonoBehaviour
    10. {
    11.     public Animator animator; // animator component that will have IK applied
    12.     public bool ikActive = false; // enables IK
    13.     public Transform leftHandObj = null; // IK target on rifle object
    14.  
    15.     void OnEnable()
    16.     {
    17.         animator = GetComponent<Animator>();
    18.     }
    19.  
    20.     //a callback for calculating IK
    21.     void OnAnimatorIK()
    22.     {
    23.         if (animator)
    24.         {
    25.  
    26.             //if the IK is active, set the position and rotation directly to the goal.
    27.             if (ikActive)
    28.             {
    29.  
    30.                 // Set the left hand target position and rotation, if one has been assigned
    31.                 if (leftHandObj != null)
    32.                 {
    33.                     animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
    34.                     animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
    35.                     animator.SetIKPosition(AvatarIKGoal.LeftHand, leftHandObj.position);
    36.                     animator.SetIKRotation(AvatarIKGoal.LeftHand, leftHandObj.rotation);
    37.                     ikActive = false; // disables IK after each adjustment
    38.                 }
    39.  
    40.             }
    41.  
    42.             //if the IK is not active, set the position and rotation of the hand and head back to the original position
    43.             else
    44.             {
    45.                 animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 0);
    46.                 animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 0);
    47.                 animator.SetLookAtWeight(0);
    48.             }
    49.         }
    50.     }
    51.  
    52.     public void DoIK ()
    53.     {
    54.          ikActive = true; // initiates IK adjustment - controlled by RifleIKActive script
    55.     }
    56. }

    The second goes on the rifle, and tells the first script what the IK target is, and initiates each IK adjustment from Update.

    Code (CSharp):
    1. // This is the IK initiator. It goes on the rifle prefab containing the IK target.
    2.  
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6.  
    7. public class RifleIKActive : MonoBehaviour
    8. {
    9.     public string iKRootTag = "Player"; // tag to find IK Root at runtime - usually Player
    10.     public GameObject iKRoot; // object containing RifleSupportIK script;
    11.     public RifleSupportIK rifleSupportIK; // script on player that does IK
    12.     public Transform iKTarget; // IK target transform on rifle
    13.  
    14.     void OnEnable()
    15.     {
    16.         StartCoroutine("GetIK");
    17.     }
    18.  
    19.     IEnumerator GetIK()
    20.     {
    21.         iKRoot = GameObject.FindWithTag(iKRootTag); // find player using assigned tag
    22.         yield return new WaitForSeconds(0.1f); // allow time to find IK Root
    23.         rifleSupportIK = iKRoot.GetComponent<RifleSupportIK>(); // get RifleSupportIK script
    24.         rifleSupportIK.leftHandObj = iKTarget; // assign IK Target on RifleSupportIK script
    25.     }
    26.  
    27.     void Update()
    28.     {
    29.         if (rifleSupportIK != null)
    30.         {
    31.             rifleSupportIK.DoIK(); // tell RifleSupportIK script to do IK adjustment
    32.             // IK needs to be re-enabled each frame by active rifle object
    33.             // This ensures that when the rifle is no longer active, IK will be off
    34.         }
    35.     }
    36. }

    When the gun is stored, it no longer tells the first script to do IK adjustments, and returns control to the saved animations. I hope this helps anyone else with the same problem. If there's a better way, let me know. o_O

    Screenshot 2021-04-30 122818_1.png
     
    Last edited: May 4, 2021
    drcfrx, TeagansDad and greatowq01 like this.
  42. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    More questions but does anybody have any documentation on setting up Dodge? There don't seem to be any examples or documentation and when I add it myself it doesn't function.
     
  43. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Mixamo's Pro Sword and Shield Pack doesn't actually include any sort of dodge animations, so it is not included in the SSMP docs and was not included in the SSMP setup scripts.

    The Archery Motion Pack (AMP) does include the Basic Dodge motion in its setup, as there is a set of dodge animations in Mixamo's Pro Longbow Pack. They're not very good -- more of a hop than a dodge -- but better than nothing.

    I discovered with some playing around that Mixamo's longbow animations, when mirrored, have roughly the same foot placement and torso rotation as the sword & shield animations. Not a perfect match, but it works. It doesn't feel fluid, as you can't start moving again until the dodge animation finishes.

    The current version of the SSMP setup script actually will set up the Basic Dodge motion if you have the Archery Motion Pack installed. I added it that way because it's the only way that I could safely assume that you have the necessary animations. Of course, it is possible to simply download the longbow dodge animations, configure them, and set up the motion and animator state machine manually.

    If you're downloading and importing the longbow dodge animations manually, you'll need to configure the root motion properties of each animation clip:

    upload_2021-5-3_11-28-46.png

    If you don't do this, you'll get awkward in-place animations instead of having the character actually dodge.

    The easiest way to get the animator set up is to comment out a few compiler directives in SwordShieldDefinitionPack.cs. Comment out the #if OOTII_AYMP and #endif lines, but leave the lines of code contained within.

    Lines 293-295:
    Code (CSharp):
    1. #if OOTII_AYMP
    2.             rMotionController.CreateMotion<BasicDodge>(rAnimatorLayer);
    3. #endif
    Lines 482-484:
    Code (CSharp):
    1. #if OOTII_AYMP          
    2.             ExtendBasicDodge(rMotionController, 0);
    3. #endif
    The SSMP setup script is also looking for four specific animation files at these locations:
    • Assets/ootii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo/standing dodge backward.fbx
    • Assets/ootii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo/standing dodge left.fbx
    • Assets/ootii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo/standing dodge right.fbx
    • Assets/ootii/Assets/MotionControllerPacks/Archery/Content/Animations/Mixamo/standing dodge forward.fbx
    You can always assign the animation clips manually after running the setup script to build the animator controller. You could also put the animation files into the above path, or just edit the SwordShieldDefinitionPack.cs at lines 2396, 2403, 2410, and 2424 to change the animation path.

    At the end of the day, Mixamo's free animation packs are quite limiting, and there's only so much you can do with them. You'll be hard-pressed to get fluid-looking and responsive-feeling combat out of them. Kubold's animation packs are probably the best you'll find on the Asset Store (as far as realistic mocapped combat animations go). I've got custom Motion Packs built for most of those sets.
     
  44. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Glad you got it figured out! IK is one area that I still haven't actually spend any real time figuring out. I've played around with Bone Controller and Final IK a little, but that's the extent of it.

    When I have the time, I may play around with these scripts and try and build something more generic and reusable for all weapon types. If that's okay with you, of course.
     
    FargleBargle likes this.
  45. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    Awesome, I'll give it a go to add it back in. I'm actually starting to understand this stuff! One thing that would be great, is there an example of or some guidance on how you might create a charge attack? Something similar to the block but as a new motion with a higher priority?
     
  46. Invirtuo

    Invirtuo

    Joined:
    Nov 30, 2016
    Posts:
    14
    Hi how can I use the Third Person Motion Controller with the new active input handling installed. It gives me error event if I set it to both? In Unity 2020 and 2019... Screenshot 2021-05-05 163019.png Screenshot 2021-05-05 163118.png
     
  47. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    There aren't any examples of how to do that. You've got the right idea with using the block motion as a template. You'll need to make some sort of animation to represent holding the weapon while it charges -- I'd probably use a few frames from the "top" of the weapon's arc in an attack animation, set to loop seamlessly.
     
  48. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    If I'm not mistaken, you have to choose one or the other. I haven't had time to sit down with the new input system to give it a try, so I'm just going on what I think I remember reading before.

    I talked to @Tryz yesterday and he said he'll be checking in on the forum here on the weekend. He should be able to give you a better answer if I'm wrong on this. :cool:
     
  49. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    Thanks for the help @TeagansDad!

    I've followed along with the YT tutorials and have finishing moves set-up by using a pre-attack call to change the attack style but wouldn't this be easier to just force MotionForm ID? I can't figure out how I would do that inside the combat message instead of changing the attack style.
     
  50. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    More questions!

    So I have finishing moves in my game, I have a specific animation & phase for this in both the player and the enemy, when I detect this is going to be a finisher I teleport the enemy to in front of the player and play the relevant animations on both controllers. Now, both have the highest priority but for some reason they’re out of sync (i animated them together and the speeds in the state machine are set correctly) is this a case of how the blending works? Is there a way I can override and just say whatever you’re doing right now just stop and instantly do this new motion?

    Thanks again for all the support and answers!