Search Unity

Motion Controller

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

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thanks everyone. :)

    I really do appreciate you understanding. I'm doing better I'm going to catch up on posts and emails today.
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Damn that looks good!! :eek:
     
    Salja likes this.
  3. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    His effects really are awesome.

    Based on what I saw with is RE4 asset, I doubt they will be "drag-n-drop". With RE4, he had some scripts that controlled the effects so they need to be able to run. As @Salja said, it's probably going to be a better fit with the Spell Casting Motion Pack as that allows for different logic flows.

    While I'm excited to play with Archery Effects, I don't want to make any promises. I've got 3 commitments out already that I've been severely delayed on. :(
     
    Weblox likes this.
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hahaha... I did think it was a funny coincidence.
     
  5. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The cool thing with motions is that it's really the same as activating a jump. We're just activating and deactivating a motion.

    In the "demo_Shooter_NPC" scene, I show an NPC rudely shooting someone in the back. The AI code (I use that phrase lightly) gives you an example. The SHMP_NPC_Controller.cs shows you how the NPC equips the gun and then activates the BasicShooterAttack motion.

    Here's some button press examples for equipping the rifle and shooting it.

    Code (CSharp):
    1. using UnityEngine;
    2. using com.ootii.Actors.AnimationControllers;
    3. using com.ootii.Actors.Inventory;
    4.  
    5. public class PressToShoot : MonoBehaviour
    6. {
    7.     private void OnGUI()
    8.     {
    9.         if (GUI.Button(new Rect(10f, 10f, 100f, 20f), "Equip"))
    10.         {
    11.             BasicInventory lInventory = gameObject.GetComponent<BasicInventory>();
    12.             if (lInventory != null)
    13.             {
    14.                 lInventory.ToggleWeaponSet(3);
    15.             }
    16.         }
    17.  
    18.         if (GUI.Button(new Rect(10f, 35f, 100f, 20f), "Start/Stop Shoot"))
    19.         {
    20.             MotionController lMC = gameObject.GetComponent<MotionController>();
    21.             BasicShooterAttack lAttack = lMC.GetMotion<BasicShooterAttack>();
    22.             if (lAttack != null)
    23.             {
    24.                 if (!lAttack.IsActive)
    25.                 {
    26.                     lMC.ActivateMotion(lAttack);
    27.                 }
    28.                 else
    29.                 {
    30.                     lAttack.Deactivate();
    31.                 }
    32.             }
    33.         }
    34.     }
    35. }
    If you use that scene I mention and put this code on the NPC (and remove the other AI script), you can use the button presses instead.
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I think it's the "Distance" values. That first value is the "minimum distance" to cast the spell. The default is "2" and that looks about where it's stopping.

    What happens if you set it to "0"?

     
  7. Necka_

    Necka_

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

    no that's not this setting, because once set at 20 the cursor is locked 20 meters away I can't move it close to me anymore

    I really think it's because of the top-down view somehow..
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Give me a day or two and I'll check on a top-down view. I'm shooting the ground ray from the camera and the character still shouldn't block.

    You're just using all my standard code, right?
     
  9. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    I've asked him about how well he thinks this would work with the Ootii MC and this was his reply:

    "I didn't test ootii, but I think it's should work.
    I use separated prefabs of effects for : projectiles, buffs, bow effects, arrow effects.
    You can just place on scene this effects, or using instantiate in runtime. It's like a standard particle system behaviour.
    Note: for arrow/bow effects I did the script, where you should set the mesh. (then effect will be automatically applied to bow/arrow mesh)"
     
  10. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    You asking kripto289, he don´t test with ootii.
    You has watch my Video ? i apply this effects to ootii motion controller, its very tricky you should be go over the "Spell Motion Pack", i activate the Spells over a simple radial menu, you select the spell and if you shot then a arrow the spell will be activate, it´s tricky but its works fine.
     
    StayUpLate and Tryz like this.
  11. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Yes I didn't touch anything, if you can't reproduce I can build a small project and reproduce
    I'm using Cinemachine here, but I don't think there is an impact as Cinemachine just place the camera in the angle I've chosen (MC has the Main Camera setup so it's all good on this side)
     
    Tryz likes this.
  12. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    This is prob really easy, but I'm not sure if this can be done through the MC ui: If I want 2 AI enemies using the m4, only one can equip it and the other one will error saying that that object already is in use. I think this is because the equip instances a clone and if that name already exists, it cannot instance the second one using that name.
     
  13. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    I've been building a pretty crazy AI using NodeCanvas together with the MC + archerypack + shooter pack + BoneController. If anyone is interested I can share the graph and you can maybe share your thoughts or just use it for yourself to build on. If you for example do not have bone controller you can simply remove that node so the enemy will not look at you while you walk past.

    This is AI for a guard. It's pretty easy to have him patrol waypoints instead of guarding a certain transform.

    Already included are checkboxes to have him only respond agressively to an armed player and leave you alone when you walk past, checkbox to choose if he chases you or stands his ground, which weapon set he uses, and chance numbers to determine if he spawns with gun in hand or only pulls gun when he needs to.

    Not 100% perfect yet but this will give you a pretty capable guard with very logical and determined behavior.

    2018-09-13 18_26_35-Window.png
     
    EvilGremlin, Tryz, Salja and 4 others like this.
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Cool. In this case, you should be able to put his effects on my arrow prefab (I'm guessing).

    My arrow prefab has an ArrowCore component that has it launch, detects impact, and causes damage. You can create your own arrow and add effects as needed. For example, I include a "FireArrow" in the asset. You'd just replace my ugly particles with his pretty ones.
     
    hopeful likes this.
  15. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Are you sure that error message is coming from my assets?

    For example, I took my simple demo_Shooter_NPC scene and duplicated "Enemy" with Ctrl-D. Then, I moved him over and hit play.

    They both equipped the M4 and shot at the PC as expected with no errors.



    "Object already in use" isn't an error I see with my assets. If you want to forward a screen shot to tim@ootii.com, I can look.
     
    StayUpLate likes this.
  16. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Simply awesome! Really really cool. :D
     
  17. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I am interested in taking a look if you want to share.
     
    StayUpLate likes this.
  18. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Come on Tim, Beauty is in the eye of the beholder, you know that :)
     
    StayUpLate and Tryz like this.
  19. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    Sure thing! I'll post the graph as soon as I'm back at my pc
     
    Tryz likes this.
  20. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    Ok thx for checking Tim! I have to play with it some more b/c then it might be my own scripting :)

    I'm making good progress on building an inventory UI that works together with the basic inventory. Once I get to a certain point I'll upload some screens. I stripped the inventory from this free asset as a base: https://assetstore.unity.com/packages/templates/packs/low-poly-game-kit-110455

    I'll contact the guy to ask how he feels about me sharing a modified part of his work. The beauty of it is in the simplicity. To anyone looking to get a basic UI with pickup/drop/use actions that is easily hooked up to Ootii's basic inventory; I got this one modified and working together in an hour or so.
     
    msik and Tryz like this.
  21. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    He goes through the complete process of how he created everything including code on his youtube channel. I also support his patreon channel as I have learned quite a bit from his youtube. The internet is a great resource for free stuff but given a chance we should support the people who give back to the community.
     
    msik, StayUpLate and Tryz like this.
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    * double like * :D
     
  23. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    100%. It might be a different discussion but if you ask me, you get better quality products/services if you go with passionate people doing their own thing - free or paid / free-market or custom work.
     
    eaque and Tryz like this.
  24. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    I've uploaded the graph JSON. You can import this within a new graph on an NPC in NodeCanvas. https://drive.google.com/open?id=148DjXozdyUu5lOUwFMwhUN1HIIr4694P

    Some things to get this setup or modified;

    - I have him equipped with bow, pistol and rifle. So that's Archery pack and Shooter pack. If you have the shooter pack it's even easier because it's literally the super agressive guy from Tim's included shooter demo copypasted into my scene, and added the archery pack to him using the packs setup; all defaults.

    2018-09-14 17_28_26-Window.png

    If you want to use your own NPC Tim has a few quick videos on how to setup a character with the MC and Nodecanvas (like this one:
    ). I just use the one from Tim's shooter demo scene because, well, he is already setup :D

    2018-09-14 17_26_58-Window.png

    - You need to get the NodeCanvas integration from the Ootii vault. Some of my nodes are Tim's custom MC nodes and they work nicely! You can also off course keep it vanilla NodeCanvas but I figured why reinvent the wheel.

    - Some nodes reference the Ootii bonecontroller activating and de-activating. This is just for the guard to stare you down as you walk by. It's the basic lookAt motor. If you do not have the bonecontroller you can delete these nodes, it's just extra.

    - And finally the agent needs a target and a guardPoint configured on it's variabeles/blackboard. Target is your player gameobject (I'm guessing) and guardpoint is just an empty transform where you want him to return to after chasing and losing you. Can be any gameobject transform. You can also send him down a pit if he loses you.

    Let me know if you have any questions or ideas for improvement!
     
    Tryz, hopeful and TeagansDad like this.
  25. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    By the way, for some Shooter pack Beta feedback; pretty much all sunshine here! Only weird bug is when I run (not walk) while targetting with RMB and in that state fall off of something. It does something weird (to the look IK?) bending my character upward. Could also be my character rigging, seeing that it had some weird behavior earlier.

    No biggie since I wanna disable running while targeting with the firearms anyway. I don't know a lot about guns but I'm pretty sure I wouldn't run while aiming. :D Is there a way to disable running while targeting?
     
  26. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    i send you a pm
     
    Tryz likes this.
  27. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    That's a very clever graph. You should do video tutorials. I'd be a Patreon for stuff like that. Information is power and Node Canvas desperately needs more good tutorials.
     
    Tryz and StayUpLate like this.
  28. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    Thanks, I take that as a huge compliment :D I was thinking about doing tutorials yes. But I'm only just a few months into gamedev and unity, so I'd like to be a bit more knowledgeable first :p
     
    Tryz and EvilGremlin like this.
  29. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    What could be causing custom character to get off the ladder (At the top) sooner than demo character?(prematurely play climb animation so character goes through a wall).
    I made all the settings identical, with exception of head bone for the top transform in body capsule settings. My character has large cartoony hair so head bone is much lower, so I used top offset parameter to make capsule size almost identical to demo character.
     
  30. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    you play already with this settings ?

    Screenshot_1.png
     
    Tryz likes this.
  31. YCE2010

    YCE2010

    Joined:
    Jan 23, 2013
    Posts:
    27
    Ok, thanks you very much. I´m stupid, lol. I really did not think about using the NPC code.
    Best regards
     
  32. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    i.png

    Got separation of inventories working :D A weapon inventory coupled to the Ootii basic inventory with working number keys and a second inventory with consumables. UI is still a bit rough and it doesn't always need to be visible, but this is just over 2 hours in from modifying Jayanam's free inventory. No changes needed on the Ootii part because I only want the character to gain weapons and not drop them. Sort of like in Zelda. (edit: ok; the older Zelda games. In BOTW you can ditch nearly everything)

    At this point I'm thinking it would be cool to have the last equiped weapon slinging on her back, but I get the sense that such a carry would require me to rig a bunch of extra carry/IK bones in Maya connected to the spine to prevent the item from clipping through the body.
     
    KeithBrown, Tryz and TeagansDad like this.
  33. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    That's pretty impressive. You've obviously got a talent for AI design.
     
    StayUpLate and Tryz like this.
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    It's super clean... I love it. :D
     
    hopeful and StayUpLate like this.
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hmmm... I think you'd have to have a small component that removes the run action alias when targeting. There's nothing built in to do that.
     
    StayUpLate likes this.
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    @Salja is right. Those setting are what you'll have to adjust for different sized characters.

    I'd start with the "Exit Test Height". That's the distance from the root (feet) where the top of the ladder is found. When we're under that distance, the "get off the ladder" animation plays. You may need to increase that for your character.
     
  37. StayUpLate

    StayUpLate

    Joined:
    Jul 29, 2018
    Posts:
    59
    Thanks :) I'm just starting out with a simple seek on sight and build layers op top of layers like an onion. :D This might also be done by FSM I'm reading now, when I have time I'll check out how FSM works. Maybe then I'll do a few tutorials.

    edit: accidentally typed some Dutch in there :eek:
     
    Tryz likes this.
  38. NaughtyMoleGames

    NaughtyMoleGames

    Joined:
    Jan 25, 2018
    Posts:
    51
    Is there a simple way to ignore all input during a pause menu? I'm having an issue where the game freezes when the time is set to 0 and a key is pressed (other than mouse clicks on UI)
     
  39. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    On the input source, just sent the 'IsEnabled' property to false when you don't want me to process input and true when you do.
     
    StayUpLate and hopeful like this.
  40. NaughtyMoleGames

    NaughtyMoleGames

    Joined:
    Jan 25, 2018
    Posts:
    51
    FML, what a huge oversite on my part. Thanks ;)
     
    Tryz likes this.
  41. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi @Tryz! So I went ahead and bought Motion Controller. I'm on Unity 2018.2.6 and I noticed after importing MC that I get some warnings every time I recompile any of my scripts:

    `UnityEngine.Keyframe.tangentMode' is obsolete: `Use AnimationUtility.SetLeftTangentMode, AnimationUtility.SetRightTangentMode, AnimationUtility.GetLeftTangentMode or AnimationUtility.GetRightTangentMode instead.'
    warning CS0618: Assets/ootii/Framework_v1/Code/Data/Serializers/JSONSerializer.cs(555,106)

    `UnityEngine.Keyframe.tangentMode' is obsolete: `Use AnimationUtility.SetLeftTangentMode, AnimationUtility.SetRightTangentMode, AnimationUtility.GetLeftTangentMode or AnimationUtility.GetRightTangentMode instead.'
    warning CS0618: Assets/ootii/Framework_v1/Code/Data/Serializers/JSONSerializer.cs(806,83)

    `UnityEngine.Keyframe.tangentMode' is obsolete: `Use AnimationUtility.SetLeftTangentMode, AnimationUtility.SetRightTangentMode, AnimationUtility.GetLeftTangentMode or AnimationUtility.GetRightTangentMode instead.'
    warning CS0618: Assets/ootii/Framework_v1/Code/Data/Serializers/JSONSerializer.cs(806,83)

    Would you mind having a look at those, please? (I'm a stickler for clean consoles :) )
     
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey @Seith, I will once I'm done with the big update that I'm working on. I don't want to do too many changes at once and since they are warnings they are harmless.

    That said, I understand. :)
     
    Seith likes this.
  43. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Sure, it's no problem, thanks!

    Here, I forgot a few more:

    There are inconsistent line endings in the 'Assets/ootii/Framework_v1/Content/Resources/Shaders/GraphicsManagerUI.shader' script. Some are Mac OS X (UNIX) and some are Windows.

    There are inconsistent line endings in the 'Assets/ootii/Framework_v1/Content/Shaders/OutlineDiffuseHidden.shader' script. Some are Mac OS X (UNIX) and some are Windows.

    There are inconsistent line endings in the 'Assets/ootii/Framework_v1/Content/Shaders/OutlineDiffuse.shader' script. Some are Mac OS X (UNIX) and some are Windows.
     
    Tryz likes this.
  44. drukengamer

    drukengamer

    Joined:
    Sep 17, 2018
    Posts:
    6
    Hi,

    First time posting.. :)

    Has anyone tried using the TimeLine with the MotionController?

    Mainly using the transform feature of the timeline to move the character.

    I can't get it to work once an Actor Controller and MotionController components are attached, even if they are disabled the character will not move. I've tried use transforms and every other setting its a no go.

    Even using the add animation clips feature doesnt work, the character plays the timeline animation(walking) but will not move. If I remove the MotionController and actor controller everything works as expected.

    Any Ideas?

    Thanks in advance.
     
  45. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    Yeah i get the same Problem in the past then i have buyed the Slate Asset for Cutscenes thats has work for me with MC, i don´t know what is the problem with TimeLine
     
  46. drukengamer

    drukengamer

    Joined:
    Sep 17, 2018
    Posts:
    6
    Ok,

    I think I have a solution, I'm not sure if this is the best method but it works great.

    public override void UpdateRootMotion in BasicIdle.cs is the culprit.

    To avoid modifying the MotionController stock motion scripts the easy way is to just make a new motion on the base layer with a basic idle pose, create a new motion script and make sure under UpdateRootMotion:

    rMovement = Vector3.zero;
    rRotation = Quaternion.identity;

    Is commented out. Then before a TimeLine is launched make sure to put the timeline characters in the empty state with the MotionController and all timeline functions then work fine.

    Hope that helps anyone if they come looking for info on this.
     
    hopeful and StayUpLate like this.
  47. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Tryz Hi, I've barely started implementing the Character Controller (following instructions from the video below) and I'm encountering an issue.



    I'm using Rewired and Cinemachine (FreeLook). I've installed the Rewired Input Source asset from this page: http://www.ootii.com/UnityMotionVault.cshtml but my problem is that the movement of the CC is not relative to the camera but instead to the current orientation of the CC.

    In other words, if I move the left stick forward I'm expecting the character to move forward in the camera space, not in its own relative space.

    Now it's a relatively common issue and easy to fix; you just need to multiply the input values by the relevant camera vectors to get the proper world direction. But I'm a bit hesitant to start hacking the ootii scripts; I mean I'm sure you must have met this situation before, or I could be doing something wrong. Would you have some insight into this, please?


    Edit:

    So just to be certain, I modified ActorController.cs and replaced (in MoveRelative) this:

    Code (csharp):
    1. mTargetMove = mTargetMove + (_Transform.rotation * rMovement);
    By this:

    Code (csharp):
    1. mTargetMove = mTargetMove + (PlayerCam.camTransform.rotation * rMovement);
    And that indeed fixed my movement direction issue. But again, I'm not sure that's the way to go about this.

    Also, I noticed that the CC doesn't rotate at all to face the movement direction. Is that a design choice? Or again am I missing something?
     
    Last edited: Sep 18, 2018
  48. YCE2010

    YCE2010

    Joined:
    Jan 23, 2013
    Posts:
    27
    Hello
    Now the shoot button works using the code of NPC, but I think that it has a conflict with InputSource because if I add InputSource and CameraRig to MotionController component I can´t shoot, the weapon try to move but without shooting. I used the code that you sent me to add to shoot button.
    Best regards and thanks you in advanced.
     
  49. Arcanebits

    Arcanebits

    Joined:
    Dec 18, 2013
    Posts:
    108
    Hello, any tip on how to set up the Shooter into an NPC, I did make a prefab out of the character in the demo scene, bring it to my scene and start copying conf... The character does all but it doesnt pull the trigger...
    In the documentation, its the only one that is fully online and no pdf, but other documentation explains how to do the NPC thing...
    Anyone achieved that?
    Cheers!
    Aldo
     
  50. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    With the AC and MC on the character, I'll want to control movement. If you want something else to control movement (like the timeline), then check the 'Use Transform" option of the Actor Controller's "Advanced" view. I talk about this in the docs and some videos, but it's especially useful for NPCs where you want something else to control the character other than root-motion.

    With this option checked, you can move the transform of the character and the AC will give up control. I'll also create psuedo input from that movement to control the animations. Obviously if you're controlling the position you'll have to watch out for things like foot-slipping, collisions, etc.

    That's a good cheat, but you shouldn't have to do that if you check the "Use Transform" option for controlling movement. :)
     
    hopeful likes this.