Search Unity

Motion Controller

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

  1. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Doesn't work for me. I don't get any error but character is stuck and doesn't 't move
     
  2. Tryz

    Tryz

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

    That's the first time I've ever had anyone report that it just doesn't work. :eek:

    Just in case, I did the following:
    1. Opened a new Unity 5 project
    2. Downloaded & imported the latest Motion Controller
    3. Opened the Assets/ootii/MotionController/Demos/Scenes/Demo scene
    4. Pressed play

    Using the mouse and keyboard I could run, jump, climb, etc.

    I then followed the documentation and enabled the Xbox controller and everything worked as well. This was with a PC using Unity 5.

    I'm happy to help, but I'll need some details:
    1. What OS are you using?
    2. What version of Unity?
    3. Did you open the demo scene and try it?
    4. What steps did you take that are different from the ones above?
    5. What other assets (ootii or non-ootii) do you have in the project?

    Any info you can give me will help me help you. :)

    Thanks
     
    Last edited: Apr 26, 2015
    ksam2 likes this.
  3. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Hi Tryz!

    Thank you,everything worked!

    One strange thing is this:

    NullReferenceException: Object reference not set to an instance of an object
    com.ootii.AI.Controllers.MotionController.OnAnimatorMove () (at Assets/ootiiMotionController/Scripts/ootii/MotionController/AI/Controllers/MotionController.cs:2038)

    Maybe is because the field of Camera Transform is set to Camera Rig, and the script was looking for Camera??Like i said,i put this code in the start of MotionController
    Code (CSharp):
    1. _CameraTransform = GameObject.FindGameObjectWithTag("MainCamera").transform;
    He find the camera rig, and since the Main Camera is the child, i think it work..maybe not?


    Thank you again for you support! :)
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    That's odd. The OnAnimatorMove() function doesn't reference the camera. So, it shouldn't have anything to do with that.

    My Line numbers are off of yours. Can you post (or email tim@ootii.com) the contents of the OnAnimatorMove() function?

    OnAnimatorMove() is called by Unity and references mAnimator. So it may be that mAnimator isn't initialized yet...which is weird since it is initialized in the Start() function.

    I know you're working on dynamically initializing the Motion Controller. Is it possible that Update() is being called before Start()?
     
  5. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    I just email you my MotionController, well i don't see update being called before start, since i just have added one line at the top of the start..o_O let me check again..maybe bad typo from myself
     
  6. Tryz

    Tryz

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

    I took the MC you emailed me and put it in a fresh project. Then, I removed the reference to the "Camera Transform" that is in the MC's inspector. When I ran it, the line you added found the camera and everything worked fine without errors. So, that's good.

    The MC line (2038) that is giving you the error is this:
    Code (CSharp):
    1. mRootMotionVelocity = Quaternion.Inverse(transform.rotation) * (mAnimator.deltaPosition / Time.deltaTime);
    There's no reference to the camera. So, it must be something else. I'm betting it's the "mAnimator" field.

    In a previous email, you said
    I think the problem is that the OrkFramework isn't calling the "Start" function of the Motion Controller. So the "mAnimator" field isn't being initialized.

    You may want to put some break-points in and follow how the OrkFramework instantiates the Motion Controller.

    I wish I could be more help, but I don't own the OrkFramework and if it's spawning things itself, it's out of my control. :(

    If nothing else, maybe you can get the OrkFramework to call the Start function.
     
  7. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Hi! Thank for all your hard work! i will remember it..;)

    I will try it with break-point and if i found something, i let you know for sure.

    Maybe its the reason that , when i start the scene, my character who got the motion controller , jump high in the air before going back on his foot, or maybe its some parameter with the mass..

    i will find it and as soon i have something a bit playable a let you know..:)

    Thank Again!
     
    Tryz likes this.
  8. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    @Tryz , finally you was right, i needed to tell Ork Framework about my new controller and camera setup, to manually give him the name of the new script,i needed to make a custom control for it,since is not the default control of Ork.

    Now everything work! :D

    Thank again!
     
    Tryz likes this.
  9. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    @Tryz ....Finally custom control on Ork Framework have helped, but the problem comeback when i spawn another player...but i find the real cause of this!YES! Is because of the Animator, i have put Animate Physic ON. o_O i forgot to remove it..that was the problem..

    Now i go to sleep..

    :D
     
    Tryz likes this.
  10. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    @modulo34 I'm glad it's all working with the Ork Framework now. That's good to know for others. :D
     
    modulo34 likes this.
  11. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    If I want to have a motion with rifle I have to make a motion with character equipped rifle then character running with rifle and so on with other weapon related things?

    And I have to write the script for the motion? :(
     
    Last edited: Apr 30, 2015
  12. Tryz

    Tryz

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

    If you want a character running, but with a rifle you have a couple of options:

    1. Use the existing motions and replace the animations. This works if your animations match up to the animations that are used in sub-state machine of the motion. For simple animations, this works most of the time.

    2. Create a new motion. Depending on how different the motion is from an existing one, you could just copy the sub-state machine and source code. Then, make changes to the copied version. This way you're not doing everything from scratch.

    If the new motion is vastly different, sometimes it's better to start from scratch. In this case, the Motion Builder's Guide can help you out. The complexity of the new motion really depends on what you're trying to do. In my video, I show building a simple motion in about 10 minutes. However, the "Crouch Climb" motion took me several days.

    3. Use Animator Layers. Unity supports layers in the Animator. So, the base layer could be a generic run (like the MC's forward motion). Then, you'd add a layer whose mask shows just the upper body. You'd then add an animation that's holding a rifle. So, the legs are controlled by the base layer and the arms are controlled by the new layer that overrides part of the run. In this case, the bulk of the work isn't really the Motion Controller, but Unity's Mecanim. So, if you like this approach, check out Unity's documentation. They talk about layers and masks.

    4. Use an IK solution. In this case, you let the motion (and its animations) run like normal and use IK to adjust the position of the arms and hands. To be honest, I'm not sure how well this works when there's large bone changes, but for holding a sword or bow it looks promising. This is the one I'm playing with right now.

    I've seen people implement a run (weaponless run, rifle run, sword run, etc.) in all these different way. I can't say one is better than the other. It depends on your skill level with animations and code.

    I'm a good coder, but horrible animator. So, I tend to like #2 if I can find/buy the animations that fit my need. I know of an animator who did a whole parkour system and used #3.

    Hopefully this at least gets you started. :)
     
    Last edited: Apr 30, 2015
  13. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Thanks bud your the best
     
    Tryz likes this.
  14. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Can I take an animation from your walk, run and idle take it to Maya add rifle To it with upper body animation and proceed with step #2? nvm that can't be done I didnt know unity does not export animations like that. I have to do it all in unity.
     
    Last edited: May 1, 2015
  15. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Actually, you can. Nearly all the animations came from Unity's Raw Mocap Data and are in FBX form. So you can import the FBX into Maya and change. Any animations I created (like the climbs) are FBXs too.

    So yep... modify away. ;)
     
    ISH_the_Creator likes this.
  16. GosuUSA

    GosuUSA

    Joined:
    Apr 30, 2015
    Posts:
    2
    I can't for the life of me get my wireless 360 controller to work.

    I am using Unity 5
    Tattiebogle driver is installed and preferences show that it's working and registering.
    Enabled the 360 controller on the GameCore.
    I went through the instructions on the PDF with no luck.
    I noticed in the input manager there's a slot created for WXRightStickX and Y, but now left stick? Or is that just default Horizontal and Vertical movement?

    Any thoughts on what might be wrong?

    Thanks.
     

    Attached Files:

  17. Tryz

    Tryz

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

    I heard of the issue two other times (once was a client that had nothing to do with the MC). In both cases, they had to install the Windows 7 drivers for the wireless Xbox controller. Once they did that, the controller worked. It seems to be an issue with the wireless controller and Unity. I use a wired controller and haven't had a problem.

    As for the WXLeftStick, you're exactly right... it's handled by Horizontal and Vertical.

    Please give the driver a try and let me know if it works for you too. :)
     
  18. GosuUSA

    GosuUSA

    Joined:
    Apr 30, 2015
    Posts:
    2
    Thanks for the quick reply! I actually have a wired controller on order from Amazon. In the meantime I'll try your driver suggestion, if that doesn't work I'll prob just wait till my wired controller comes :)
     
    Tryz likes this.
  19. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Hi
    I have a noob question. there is some animations like walk، ran and ... they plays with keys like "S.W.A.D، Space and..." I want to add some new animations but how can I play them with keyboard keys? I mean for example walk animation plays when we pressing "W" key or ... now I want add a shot animation but how can I play my animation with keyboard keys?
     
  20. Tryz

    Tryz

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

    Assuming you created a motion for your animation, you'd use the ootiiInputStub class. I talk about it in the User's Guide on page 25.

    Let's take "Jump" for example. You have a Jump motion and want to see if it's time to run it (and it's animations). Your motion would do something like ootiiInputStub.IsJustPressed("Jump"). Then inside the IsJustPressed function of the ootiiInputStub, you'd put the test for your keyboard keys and return "true" or "false" as appropriate.

    This way, you can use the standard Unity Input class or another input solution and your motion won't care.

    I hope that make sense.
     
    ksam2 likes this.
  21. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Hi again @Tryz ! I have make big step with the Motion Controller! :D ,but i wanted to know for the Adventure Rig script, since i dynamically assign the controller field,for time to time ,it didint find it,i think its a priority timing in the step of Ork Framework, but removing this line from the start
    Code (CSharp):
    1. _Controller = GameObject.FindGameObjectWithTag("MainPlayer").gameObject.GetComponent<MotionController>() as Controller;
    ant put it in the update fix it, but can it cause a problem?

    Thank !
     
  22. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    You could. but it would be agonizingly inefficient.

    Can't you just put a reference in Awake(); no you can't... see next mail...

    Then setup a method to set it when you know it will change. and set a flag;

    Code (csharp):
    1. bool WeNeedToUpdateTheControllerLinkage = false;
    2.  
    3. // if you could ....
    4. Awake(){  // or Start or wherever
    5. UpdateControllerLinkage();
    6. }
    7.  
    8. // but you can do...
    9. Update(){
    10. //..blah
    11. if(WeNeedToUpdateTheControllerLinkage || null == _Controller)
    12. UpdateControllerLinkage();
    13. //.. blah
    14. }
    15.  
    16. UpdateControllerLinkage(){
    17. _Controller = GameObject.FindGameObjectWithTag("MainPlayer").gameObject.GetComponent<MotionController>() as Controller;
    18. WeNeedToUpdateTheControllerLinkage = false;
    19. }
    20.  
    21. SomeOtherMethod(){
    22. DoCrazyControllerChanges(); // or whatever
    23. WeNeedToUpdateTheControllerLinkage = true;
    24. }
    25.  
    26.  
    27.  
    That would reasonably good

    Although, there MUST be a reference to the player that is already valid by that point...
    (and if there isn't I would setup a public static reference in the ORK AWAKE())

    So I could then go:
    _Controller = ORK.MainPlayerReference.GetComponent<MotionController>() as Controller;
    to save me at least one of those slow and dirty lookups.

    And at that point I would probably move a lot of this junk to over there.
    (If I absolutely had to, but ideally in some other class)
    Code (csharp):
    1. // add the right "usings"
    2. public class StupidORKHelperClass{
    3. public static MotionController _Controller;  // don't think this needs "new"ing
    4. }
    then in ORK's statup somewhere. (I don't have ork, so I can't be specific)
    After ORK has assigned most of the junk (probably near the bottom if you can't be bothered/are unable to read the code)

    add a
    Code (csharp):
    1. StupidORKHelperClass._Controller  = GameObject.FindGameObjectWithTag("MainPlayer").gameObject.GetComponent<MotionController>() as Controller;

    So I could then do this in my other code later on...
    _Controller = StupidORKHelperClass._Controller;

    and just keep that updated via that reference to it.

    That would be cleaner I suppose
     
    Last edited: May 7, 2015
    modulo34 likes this.
  23. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    If you put a condition around it, it would work. Something like:

    Code (CSharp):
    1. if (_Controller == null)
    2. {
    3. ...
    4. }
    Otherwise, twobob is right and performance will suffer.

    @twobob , I think the underlying problem is that the Ork Framework is creating and initializing the MC so Awake() is never called. He put in code to have it called, but the order that Ork does it seems to be an issue (randomly).
     
    modulo34 likes this.
  24. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    ah.
    if (_Controller == null) UpdateControllerLinkage();
    then.

    The horror, The horror...

    :)

    EDIT: I updated my example then...
     
    Last edited: May 7, 2015
    modulo34 and Tryz like this.
  25. richardvertigo

    richardvertigo

    Joined:
    Dec 19, 2012
    Posts:
    12
    We have the same problem. - clean install (unity 5.0.1f1) - the character get stuck when climbing without any error messages.

    @Tryz What Unity version are you using?
     
  26. Tryz

    Tryz

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

    I'm using 5.0.1f1.

    So, I just did a clean import again and it stopped in the climb for me too.

    I closed Unity 5 and reopened it and then it worked. In previous "fresh install" tests, it just worked without the close/reopen.

    Not sure why that's happening, but can you see if that works? I'll have to dig into what Unity's doing as this wasn't an issue before. :(

    .
     
    Last edited: May 7, 2015
  27. richardvertigo

    richardvertigo

    Joined:
    Dec 19, 2012
    Posts:
    12
    Restarting Unity did the trick. Thanks!
    Good luck fixing this very weird bug.
     
  28. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Right. :eek:

    It just hit me... I did a post on this a while back (top post page 11). Unity 5 seems to "lose" Animator connections after updating from the Asset Store. A restart brought them back. I've never seen it on a fresh install before... just an update.



    Ugh.
     
    twobob likes this.
  29. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Don't know what you think Tryz... might be worth breaking out the reflector (*cough or IDA cough*) see if there isn't a way to "check for such breakages and fix" via code.

    Sounds like a "saleable" item to me ;)
     
    Tryz likes this.
  30. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    Animator Controller! :)
     
    Tryz and twobob like this.
  31. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    @twobob and @Tryz , thank to both of you, i will try one of these answer :D
     
    Tryz and twobob like this.
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hahahaha!!! You crack me up.

    Unity's animator API is pretty sweet too. It's working in MC2 to auto-generate the complete animator sub-state for each motion. So far, that's working out really well! ;)
     
  33. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Hey Mr Ootti,

    I'm working hard on the new motions, I made a modified rig to a fuse character putting a extra bone on both hands

    parenting it to the hands base joint. The motion is (equip riffle, unequip riffle, Riffle idle), All in witch I was planning to mask

    over your locomotion copy call it rocomotion lol. Its only a joint on the hands like a second thumb thats only purpose is to

    move a riffle. Then I have melee (kick, punch or kick punch combo) with the same inputs that would fire (right botton

    Trigger on xbox or left mouse button) when character is in locomotion with no rifle. If I'm able to finish tweaking animations

    I will post all the animations this week end. thought about using mount points but have not bought it yet. I know your busy

    so I will try and keep it simple.



    And I didn't know that Adventure Creator supports MC

    http://www.adventurecreator.org/tutorials/adding-custom-motion-controller

    THATS GGGGGRRRRREEEEAAAATTTTT :)
     
    Tryz likes this.
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    That all sounds pretty cool! I'm curious to see how it all comes out.

    I didn't realize the Adventure Creator had a tutorial for MC! haha. That's awesome. :D
     
  35. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    MC rocks
     
    Tryz likes this.
  36. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Here is my animation set I had purchased a while ago. Why key frame when you don't have to right lol.

    I have alot of fixes but that part is easy. I just have to tweak some more. I added a joint on each

    hand on the character but now thinking others will have issues with there own gun. I parented

    the gun to that joint for unequip its not working yet but will soon. Or maybe theres a better

    way with Ootii's Mount Points I am just used to rigging everything but I think thats my next

    purchase to get this to work the way I want as well as help the community.

    When done I will make it a new motion for all to use.

    Mr OOtii, As far as controls go and its up to you, But the motions will act as locomotion but in 3 layers.

    1. Gun equip and all the same kinda locomotions and can jump

    2. Crouch and all the same kinda locomotions not sure if jump is logical or not for type of game play

    3. Laying down on ground and same kinda locomotions can't jump while on ground

    *Was thinking to map idle to crouch by pressing down on d pad, Down again to lay down, Up to

    crouch from lay down, Up again to normal idle. When pressing Left analog stick in run for a

    period of time it over rights Crouch and laying down to get up and start running.

    A feature in Easy Input :) (how long keys are pressed)

    *equip ? well I'm not sure, Left or right D pad but will players press it often on mistake?


    Oh I forgot to mention zoom Shoot will just work with Adventure Camera? right lol

    I'm game on what ever is best.

    Are there plans for AC to have sniper cam when Sniper Rifle is equipped zoom goes to supper

    zoom :p



    Here's the Gun I love and dream about playing with in my project

     
    Last edited: May 12, 2015
    Tryz likes this.
  37. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Great animations!

    In order to make the current motions as flexible for everyone, I introduced the "ootiiInputStub". This creators to add code like this to the motion:

    if (ootiiInputStub.IsJustPressed("Jump")) { ... }

    The idea being that we can default the contents of ootiiInputStub.IsJustPressed to test the argument "Jump" with something like the space bar. However, users can replace the contents and change the controls without having to change the motions. I think if we follow this standard, you could set the default controls to what make sense and people can override. But, I'll help how I can.

    BTW, it's been a while since I've played a shooter :cool:. Shadows of Mordor, Assassin's Creed, and the like are my current obsessions. :)

    Layers are good, but when I see the ones you've listed... something seems a bit off. Lower layers override the previous layer. So I typically don't think about layers as totally overriding the whole body. So, I tend to think about layers like this:

    1. Whole body defaults (idle, walk, run, crouch, prone, jump, etc)
    2. Upper body adjustments (hold pistol, hold rifle, hold rocket, hold sword)
    3. Facial adjustments (eyes, talking, head turns)

    I'm not saying it has to be this way, but I like letting the motions control #1 and then using layers provide adjustments.

    If anyone has any other experiences, it may be good to hear them too.

    Yes! :)

    No! :(

    While I do have an over-the-shoulder aim mechanism that matches Tomb Raider, I don't have a zoom that you'd find in typical shooters. It's something that's been on the top of the request list for a long time, but I've never gotten to it. Some day when the work, kids, and life slow down... I promise I will. I just don't know when that will be. :eek:
     
  38. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    yeh you right, I get very ambitious at times. the Metal gear series is my all time love. and Assassin's Creed black flag best

    ever. Well I understand

    yeh you right, I get very ambitious at times. the Metal gear series is my all time love. and Assassin's Creed black flag best

    ever. Well I understand the layers of motions.

    maybe what I was thinking requires custom coding perhaps.

    All good Mr Ootii, take your time. I still got to get really good at scripting first lol:)
     
    Tryz likes this.
  39. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    http://unity3d.com/unity/beta/unity5.1.0b3
    Fixes:
    Mecanim: Fixed transitions disappearing when importing a project from 4.x

    Hmm... possibly good news?

    Laterally:
    Profiler: Fix lockup in editor, if left in background with the profiler open
    Gosh I hope so this time... ;)

    hmm... we are up to b6... shouldn't be long now... (he said presciently, he hoped)
     
    Last edited: May 13, 2015
  40. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I'd heard a bit ago that 5.1 was expected to hit in the early summer. So maybe a month out, -ish?

    There are some other animation improvements that should be helpful in 5.1, I believe. Mirroring, not losing animation states when a model is set inactive, etc. We'll see what we get when it's released, but it sounds like it should be a good point release for mecanim. :)
     
    twobob likes this.
  41. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    I'm still somewhat new to coding, but working hard at it. I'm going through the docs and digging through the scripts, but can someone give me a simple description of how a controller input ultimately triggers a motion? Having trouble following the chain of events.
     
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey, I should be able to help. :D

    Each motion has a "TestActivate()" function that is called every frame by the Motion Controller (MC). If that function returns "true", the motion should be activated.

    So, in it's very simplest form you could have a "Jump Motion" and inside it's TestActivate() function, you'd test to see if the player pressed "button 1" on the controller. If they do, you return true. If not, return false.

    You can test this input anyway you want. For example, you could use Unity's "Input" class and do something like this:

    Code (CSharp):
    1.  
    2.         public override bool TestActivate()
    3.         {
    4.             return UnityEngine.Input.GetButtonDown("Fire1");
    5.         }
    6.  
    At it's most basic form, this is how you trigger a motion from input. You'd just follow Unity's standard input testing and return true or false.

    That's it. :)


    In the motions I share with everyone, I use the "ootiiInputStub". The reason is that you may like using Unity's standard Input class, I may like to use Easy Input, and others may use a different asset. With ootiiInputStub, users can use it to test for input (any way they want) without having to modify the motions.

    I hope that helps.
     
  43. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    61
    Thanks, Tim! That does help.

    I was digging in Sneak.cs, and the TestActivate function for sneaking contains this:

    Code (csharp):
    1. if (mController.State.Stance == EnumControllerStance.SNEAK ||
    2.     mController.State.Stance == EnumControllerStance.TRAVERSAL && ootiiInputStub.IsJustPressed("ChangeStance"))
    But I can't find a reference to ChangeStance in the input settings or ootiiInputStub.cs. What am I missing?
     
    Last edited: May 18, 2015
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Remember, ootiiInputStub just passes the input request to what ever input manager you use. By default, the Motion Controller uses the InputManager.cs file found in the "Assets\ootii\MotionController\Code\Input" folder.

    At line 375, you'll find this:
    Code (CSharp):
    1.             else if (rAction == "ChangeStance")
    2.             {
    3.                 if (UnityEngine.Input.GetKeyDown(KeyCode.T)) { return true; }
    4.  
    5.                 if (mIsXboxControllerEnabled && UnityEngine.Input.GetAxis("WXRightTrigger") > 0.5f)
    6.                 {
    7.                     if (!mOldRTrigger)
    8.                     {
    9.                         mOldRTrigger = true;
    10.                         return true;
    11.                     }
    12.                 }
    13.                 else
    14.                 {
    15.                     mOldRTrigger = false;
    16.                 }
    17.             }
     
  45. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Hey, great asset! I purchased this awhile back and have been enjoying how modular this system is.

    Instead of the motion that came with the asset, I've adapted the movement blend tree from Character System. Things have been working fine except that the animations aren't blending with each other like they should, even those they're all part of the same state machine and the animation never leaves said state machine.

    For example, when my avatar moves forward, and then I press the strafe left key, the avatar is supposed to blend into a diagonal strafe. Instead, the avatar just snaps into that diagonal strafe. When I preview it in the animator by adjusting the parameters, the blending is smooth as it should be.

    Could you give me some guidance on this, Tryz? Or does this sound more like a Mecanim thing? I can't quite be sure myself.
     
    Last edited: Jun 1, 2015
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey Cyangamer1,
    I would look at what you're getting in the Animator Parameters and see how that compares to what is setup with the blend tree that you created.

    There isn't a delay in sending the input. So, that should just happen immediately.

    You used the term "blend tree", but then said "even those they're all part of the same state machine". Just to make sure we're on the same page... a "blend tree" is a single state with multiple animations. That's different than multiple states (with one animation each) that transition from one to another. As you transition from state to state, make sure you have a duration set. This will allow the states to blend smoothly.

    Blend trees can be touchy. Take for example an idle-walk-run-sprint blend tree. If you're sprinting and then stop immediately, you don't just drop to a different state. Instead, the blend tree quickly goes from sprint -> run -> walk -> idle... then you transition. That can look a bit odd.

    Definitely
    start with the Animator Parameters and make sure you're getting what you expect. If you are, than look at the blend tree or state nodes. It could be your transition timings.

    I hope that helps.
     
  47. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Sorry, you are right. When I said state machine I actually meant state, which contained this blend tree.

    Anyway, thanks for your advice! It helped me look at my blend trees in a slightly different perspective, and that helped me figure out the issue.

    The blend tree from the CS used Mouse X instead of Input Angle from Camera/Player. Mouse X has bounds from -1 to 1 while the angle parameters obviously are in degrees. I just changed the threshold values from -90 to 90 I the blending worked as expected.
     
    Tryz likes this.
  48. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Hi Tryz, I have another question:

    I've created a separate Backflip motion. Just uses 1 animation clip -- it's pretty simple, only nonstandard requirement is the player has to be moving backwards (so InputY < 0) for the motion to activate. However, when it's activated, the animation clip only goes part way before it reverses and then the controller goes back to the SimpleForward motion.

    Some debugging revealed that, for some reason, the Backflip motion isn't staying active through the end of the animation clip. It's possible that SimpleForward is interrupting it, but I don't know how to keep it from doing that if the system believes that the Backflip motion is ending before it is supposed to.

    To be clear, I'm using this to show if the backflip animation state is active:
    Code (CSharp):
    1. if (lTransition == "Entry -> " + lBaseLayer + "Dodge-SM.roll_back" ||
    2.                     lTransition == "AnyState -> " + lBaseLayer + "Dodge-SM.roll_back" ||
    3.                     lState == lBaseLayer + "Dodge-SM.roll_back")
    4.                 {
    5.                     return true;
    6.                 }
    Unfortunately, the above condition returns true for only about one frame and then returns false, even though the animation clip in question (Dodge-SM.roll_back) is still playing.

    Do you have any advice on this?
     
  49. Tryz

    Tryz

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

    The MC won't automatically block as an animation runs through until the end. This allows you to bail out mid way if needed. In this case, it seems like it's bailing out before you want.

    I think what I'd do is take advantage of the "OnInterruption()" function. This function is called when the motion is active, but some other motion wants to take over. In this case, your "Backflip" is active and "SimpleForward" wants to take over.

    To prevent the interruption, return "false".

    You'll override OnInterruption() in your Backflip motion and do something like this...

    Code (CSharp):
    1. if (mController.State.AnimatorStates[mAnimatorLayerIndex].StateInfo.normalizedTime > 1f)
    2. {
    3.     return true;
    4. }
    5. else
    6. {
    7.     return false;
    8. }
    This will only allow the interruption if the animation has finished (ie gone past 1.0 normalized time).

    Using Unity's "StateInfo" object is probably the best way for you to test if you've finished the simple animation. It's fast and won't cause any allocations like string manipulation does.

    Let me know if this helps,
    Tim :)
     
  50. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Thanks, that helped.
     
    Tryz likes this.