Search Unity

Motion Controller

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

  1. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I was testing some new doors a while back, and ran into something weird. The door frame mesh collider had an opening over 1m wide, and 2.4m high. My player was 1.8m tall, had a body capsule with a radius of .3m, and Unity colliders enabled. You'd think there would be enough room, but he still couldn't get through. If I widened the door frame enough, he could finally pass, but then the door didn't look right. I posted about it at the time, but got no answer, so I set it aside and worked on other things. I ran into the problem again today when trying to walk between two side rails on a 1m wide stairway.

    Door_Collider_Pushback1.jpg

    After digging into the Actor Controller collision properties, I discovered that turning off the Pushback feature solved the problem. Is there any way to have Pushback enabled and still walk through reasonably sized doors? I'd like to have both features. So do I need to have scripts on all my doors that turn Pushback off while going through them, or can it be configured some other way to allow door passage? The manual says there's a performance penalty when using it, so should it only be enabled when the player is about to get hit by something?
     
    Last edited: Nov 20, 2020
  2. Tzirrit

    Tzirrit

    Joined:
    Sep 9, 2014
    Posts:
    23
    No worries, it's not a blocking issue!

    The FoA indicators are just a very nice tool, especially when fine-tuning combat. Actually, they were one of the key selling points that made me pick the ootii suite in the first place :)
     
    Tryz likes this.
  3. Tryz

    Tryz

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

    I did some work to make the graphics rendering more reliable and usable. One of the new features disables the rendering of the debug graphics in the game view by default.

    If you open PSS_MotionBase.cs, you'll see several lines of code start with "Graphics.GraphicsManager". Like this:
    Code (CSharp):
    1. Graphics.GraphicsManager.DrawCollider(lWeaponCore.Collider as BoxCollider, rColor);
    There is now a new parameter used to determine where rendering happens:
    Code (CSharp):
    1. Graphics.GraphicsManager.DrawCollider(lWeaponCore.Collider as BoxCollider, rColor, null, 0f, Graphics.RenderScope.ALL);
    The default is now "Graphics.RenderScope.EDITOR" which means I'll only render to the scene view and not the game view. To render to game view, it would need to be set to "GAME" or "ALL".

    By default, I do think it's better in EDITOR only. So, I'll change the code to use ALL when the "Show Debug" is checked in the motions.



    I emailed you the updated code. Let me know if there are any issues.
     
    Tzirrit and TeagansDad like this.
  4. Tryz

    Tryz

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

    Sorry about missing this earlier.

    I put together a quick demo and to be honest, I thought I would see exactly what you mention. However, the door frame didn't block me even with "Allow Pushback" checked.



    The way I built my doorway was with 3 different cubes (2 sides + 1 top). I set them all to the "Default" layer and then I had my "Collision Layers" set to include "Default".

    Could you email me a small project with a sample that's not working? I'm wondering if it's some other setting that's getting in the way and it's probably easier for me to poke through your settings on my machine.

    As for the performance hit... I only test for collisions when the character is moving. This way I'm not wasting cycles if the character is just standing around. This helps when there's lots of characters in the scene. With "Allow Pushback" checked, I have to check collisions all the time because an object could move into our character and we want to react. The impact on a hand full of character's isn't anything. However, I could see there being an issue with 50+. So, I put the warning in.
     
    TeagansDad likes this.
  5. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Is there an easy way to forcefully set the CameraRig / <OrbitRig>() rotation through the transform properties in the inspector?

    I'm looking for a quick way to have it match the orientation of the player at spawn without having to do extra math.
     
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Use the CameraRig.SetTargetYawPitch(Yaw, Pitch, Speed) function. It's relative to the character. So, a "0" yaw and "0" pitch will center the camera behind the character.

    You can't do it through the inspector since that's not around in the builds and I keep the values managed internally.
     
    Zante likes this.
  7. digitalbreed

    digitalbreed

    Joined:
    Oct 14, 2017
    Posts:
    10
    I would like to use the Motion Controller with Shooter Pack and Scroller Camera Rig to build a side scroller where the player turns and points the gun towards the mouse position.

    Navigation worked nicely already (with Adventure Style and Freeze Position turned on for Z on the Actor Controller) but since I added the Shooter Pack the player keeps turning towards the camera's forward vector (-Z) after start and A/D keys don't turn but strafe. I managed to avoid the turning by unticking the "Rotate with Camera" flag on several motions, but I can't manage to get the movement style back. Even after clicking on the corresponding inspector button again, A/D keep triggering strafing instead of turning.

    EDIT: I managed to get the pivot movement back by disabling the "Basic Walk Run Strafe" Motion with priority 6, but now the player won't move at all when equipped with a gun...

    How can I get the Adventure Movement style back, so the character will pivot towards the corresponding direction?
    And what would be the best way to make the player aim towards the mouse position? Raycast mouse into scene and position a hidden target object accordingly?
     
    Last edited: Nov 22, 2020
  8. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    That seems to be the key. When putting together a test scene, I tried using unity box colliders for the door frames instead of the mesh colliders I'd been using. With pushback enabled, I can walk between 2 box colliders, but not through an identically sized hole in a mesh collider. It seems to evaluate mesh colliders as convex even when they're not.

    But wait - on my sea stair, I discovered that I can walk UP the stair with no problem, but can't enter the stairway from the top when using a mesh collider. Now I've got no idea what's happening, other than that mesh colliders give inconsistent results when pushback is enabled. I'll email you a sample project with both types of colliders so you can see what I mean. I'm not sure if there's a simple solution - other than not to use mesh colliders - but at the very least, this potential unwanted behavior should be documented. :eek:
     
    Tryz likes this.
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I didn't really build the shooter for a side-scroller, but by making a couple of tweaks I was able to get it to work as you describe.

    Things like aiming based on some hidden target isn't something that exists, but the motions could be customized to do it. Really this is just spine IK. So, you could add it outside of the motion too.

    Email tim@ootii.com with your MC and Shooter MP info and I'll send you some updated files that will get you close to what you're looking for.
     
  10. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    Problem solved: After looking at my test scene, @Tryz noticed that I didn't have read/write checked on the imported FBX files. Apparently this is required for MC/AC to process collisions properly. If anyone else runs into weird mesh collider issues with Motion Controller, check this first. It's a simple fix, and could help in other scenarios as well.
    Thanks Tim! :)
     
    hopeful and Tryz like this.
  11. Tzirrit

    Tzirrit

    Joined:
    Sep 9, 2014
    Posts:
    23
    @Tryz using the updated script you've sent me, all attack and blocking graphics we're rendered again. Thanks!

    And I agree, only displaying them in the Editor by default is probably a good idea.
     
    Tryz likes this.
  12. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    Hello @Tryz
    ,

    I am getting the following error: Assets\NavMeshComponents\ootii\Editor\Framework_v1\Input\UnityInputSystemSourceEditor.cs(126,13): error CS0103: The name 'mRemoveExistingEntries' does not exist in the current context

    where is mRemoveExistingEntries defined?
    mRemoveExistingEntries = EditorGUILayout.Toggle(new GUIContent("Replace Existing Entries", "Determines if remove existing entries before adding."), mRemoveExistingEntries);

    GUILayout.Space(5f);

    if (GUILayout.Button("Create Input Actions", EditorStyles.miniButton, GUILayout.MinWidth(30f)))
    {
    CreateInputEntries("Player", mRemoveExistingEntries);
    }

    I have installed camera controller, third party controller and some of the action controllers
     
    Last edited: Nov 23, 2020
  13. scarpelius

    scarpelius

    Joined:
    Aug 19, 2007
    Posts:
    966
    Hello,

    How can I implement an always run button with ootii 3rd person controller?
     
  14. Tryz

    Tryz

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

    It's a bug and I uploaded a new version of the MC. Once Unity approves version 2.810, you can download and it's fixed.

    Until then, just add the following line to UnityInputSystemSourceEditor.cs around line 28 (doesn't have to be exactly that line):
    Code (CSharp):
    1. private bool mRemoveExistingEntries = false;
    Unfortunately, I have to support lots of versions of Unity and some people use the new input system package and some don't. So, there's some conditional code in place. This variable was in the wrong compiler pre-directive. It's fixed now.

    I'm sorry and thanks for understanding,
    Tim
     
    TeagansDad likes this.
  15. Tryz

    Tryz

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

    In the "Walk Run" motion (ie Basic Walk Run Pivot), there's an option for "Default to Run". Check that checkbox and the character will run by default.

     
    TeagansDad likes this.
  16. scarpelius

    scarpelius

    Joined:
    Aug 19, 2007
    Posts:
    966
    Thanks @Tryz for the fast answer it helps, I was looking for that as well, but I fear I didnt explain myself correctly.

    What I meant to say how can I make the character run after I just press a key once, like Num Look in WOW and after that the player just controls the direction without pressing the forward button.
     
  17. CThayer

    CThayer

    Joined:
    Oct 21, 2018
    Posts:
    7
    Hi Everyone,

    I just bought the Motion Controller asset and I am trying to get it setup for the first time. However, it seems like there may have been a problem with the import. I've tried importing the package three separate times but the custom highlighting and icons in the inspector seem to be missing. For example:

    upload_2020-11-24_21-19-18.png

    In all of the documentation, videos, and screenshots from other people, there is usually some orange highlighting and there is an ootii icon but, in mine, none of that shows up. Also, when I ran some of the demos it seemed like there were some other problems like the sensitivity being insanely high or some actions not working properly (i.e. climb only goes 2 steps up the ladder).

    I apologize if this has been covered here previously but I tried to search this forum thread and I haven't found anything so far. Has anyone else encountered this? Does anyone know if this means the import didn't work correctly? Or is it just some sort of purely cosmetic bug?

    Thanks in advance for any help you can provide!

    P.S.
    In case it matters I am using the latest Version 2.810 of Motion Controller with Unity 2019.4.4f1 and I ran the import through the package manager inside Unity.
     
  18. Tryz

    Tryz

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

    I don't think I've seen that before. Are you using Windows or Mac? What version of Unity?

    My only guess is that it has something to do with your system configuration. The orange color and icons have been the same since Unity 2017.

    Maybe the OS and versions will give us a clue.
     
  19. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Ahh... For this, I'd create a custom Input Source.

    With that, you can control the MovementY property which determines the backward/forward speed. Normally, it returns -1 to 1 based on the keys pressed or gamepad. You could add logic that forces the value to "1" based on num-lock, tapping, or anything.

    To learn more about Input Source, check out this post:
    https://ootii.com/knowledge-base/input-sources/
     
    scarpelius likes this.
  20. Tzirrit

    Tzirrit

    Joined:
    Sep 9, 2014
    Posts:
    23
    @CThayer Are you using Unity on a screen with 4k resolution? The same happens for me, as well and I am using 4k with scaling.

    The problem seems to be that unity does not like GUI scaling in combination with custom inspectors.

    So the option is to either disable scaling (not an option for me), or live with the buggy display.
    upload_2020-11-25_14-36-25.png

    I've also noticed the inspectors are drawn perfectly fine, when I detach them and move them to my second screen which uses a regular 1080p resolution. Which is my solution, especially when using the Spell Editor, which needs the custom Inspector to be working correctly.
     

    Attached Files:

    Last edited: Nov 25, 2020
    Tryz likes this.
  21. CThayer

    CThayer

    Joined:
    Oct 21, 2018
    Posts:
    7
    Hey, thanks for the fast responses!

    @Tryz I am running Windows 10 Home (version 2004 build 19041.063) and Unity 2019.4.4f1 but, I think that @Tzirrit found the problem. I'm NOT running a 4K screen, but I was running 125% scaling in my OS settings. The moment I changed it to 100% scaling everything looks like it should (but you know, sort of tiny, hahaha). It sounds like this is just a Unity bug with their custom inspectors. Good catch @Tzirrit!

    I feel a lot more confident that the import wasn't an issue. Thanks again for the help!
     
    Tryz, TeagansDad and Tzirrit like this.
  22. Dermestes

    Dermestes

    Joined:
    Aug 9, 2015
    Posts:
    13
    @Tryz,

    I have worked on getting the Motion Controller to work with Mirror based on your UNET code in BasicActorNetworkSync but it seems that I am still having the issue of missing some parameter changes that cause the characters to slide and get stuck in different poses which you tried to resolve over the standard network animator. Have you ever looked at making a tutorial with Mirror instead of UNET? Also looking to make it server Authoritative but even client would be helpful at this point.

    Thanks,
    Dermestes
     
  23. embbebe

    embbebe

    Joined:
    Nov 26, 2020
    Posts:
    3
    Hello, can you walk/run/sprint and simultaneously cast spells with Motion Controller and Spell casting pack?
     
  24. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    Hi @Tryz,

    Is this video still valid for creating new motions:
     
  25. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    Hey @Tryz,

    I added a motion controller and got this error message:

    ndexOutOfRangeException: Index was outside the bounds of the array.
    com.ootii.Actors.AnimationControllers.MotionControllerLayer.UpdateMotions (System.Single rDeltaTime, System.Int32 rUpdateIndex) (at F:/project/Assets/NavMeshComponents/ootii/Assets/MotionController/Code/Actors/AnimationControllers/MotionController/MotionControllerLayer.cs:436)
    com.ootii.Actors.AnimationControllers.MotionController.OnControllerLateUpdate (com.ootii.Actors.ICharacterController rController, System.Single rDeltaTime, System.Int32 rUpdateIndex) (a
     
    Last edited: Nov 27, 2020
  26. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    @ddesmond - The "ootii" folder should be directly under "Assets" as there are some hard coded file paths in the Editor code. I can't say with total certainty that this is the problem, but it's the first thing I would try.
     
  27. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    I have noticed that the getting started video does not have a controller set in the animator. I was able to get it working by setting an animator. Can you clarify?
     
  28. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    thanks, I may have dragged the folder by accident, I'll give it a try.
     
  29. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    Does anyone have any 'quick start' tips to setting up the motion controller to work in first person mode?

    I'm looking to do what Tim outlined at the bottom of this page on the Ootii website:

    So, if we do the same things with the Motion Controller you’re totally fine to use it with a first-person perspective.
    • Remove the character’s body
    • Fix the camera to a position above the main transform
    I started by creating an empty gameobject and adding the motion controller component in 'Shooter Style'. I also own the Camera Controller so it was added automatically and I've configured it in '1st Person Style'.

    So far, so good. The camera defaulted to roughly where the head would be and the MC body shapes allow the character to stand on the ground. Looking around with the mouse is fine, and I can move forwards and backwards.

    However, for some reason pressing 'A' and 'D' allow the character to strafe...but always in the same direction (to the right). Interestingly, if I'm pressing 'A' (and the character is moving right) and then press 'Shift' (to sprint) the character will start moving left as intended.

    No idea if this issue is related to the unusual 'no body' setup I'm going with, or something entirely unrelated (this is my first time using Ootii products, having bought these two assets in the sale).

    Any help is appreciated! :)
     
  30. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    I moved the ooti back to under the assets folder with no success. The steps in the video do not appear to be working, unless I am missing anything obvious.
     
  31. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    Further to this, I created a new scene, added the Player Template prefab (ootii\_Demos\_QuickStart\Prefabs\Basic Templates\Player_Template) to it, and attached the motion controller component in Shooter Style.

    This one moves correctly ie 'A' causes him to strafe left, and 'D' causes him to strafe right. However, I did notice that the running strafe left animation looks odd ie it isn't a mirror of the running strafe right.

    Watch the angle of the shoulders in the following video. For some reason he faces north-east when run strafing both right and left:


    I'm wondering if this is another symptom of whatever problem is causing my strafe left to not work with 'no body' and the first person camera, but does work if I run strafe left?
     
  32. Tryz

    Tryz

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

    As I think you found, the error is reporting there's no 'Controller' set in Unity's Animator component. You definitely need that as it's the foundation for Mecanim and all of the animations.

    The "MC 2.8 Setup 01" video shows the "MC_Humanoid_01" controller. However, the "Basic" view setup will set "Humanoid" when you press one of the Movement Style buttons with no Controller set.

    What you may be seeing is that the "Animator" on the MC isn't set. That will automatically be found if it doesn't exist. However, that Animator component needs the Controller property set.

    Set the Controller property on the Animator and you should be good.

    You can find my Humanoid controller here:
    <project>\Assets\ootii\Assets\MotionController\Content\Animations\Humanoid
     
  33. Tryz

    Tryz

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

    I'm not sure if you saw this, but the other day I created another post on using the MC + CC for first person. This includes a link to some code and a demo:
    3rd Person to 1st Person

    I just opened that scene and disabled the "Joints" and "Surface" of my character that represents the visual body. Everything else is the same and it worked as I'd expect. Give that a look and see if it help.

    In the sample scene, pressing "F" moves from 3rd person to 1st person. When in 1st person mode, I use the Basic Walk Run Strafe motion and A & D work as we'd expect. I can't think of a reason they wouldn't.



    Please give the sample scene above a try and let's go from there. Maybe it's something simple we're missing.

    If it doesn't work, go ahead and email tim@ootii.com your scene and I'll take a look.
     
  34. embbebe

    embbebe

    Joined:
    Nov 26, 2020
    Posts:
    3
    Hello, @Tryz

    I am getting these warnings suddenly. why it happens? Unity Editor 2020.1.14



     
    Last edited: Nov 28, 2020
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The "Spider AI Driver" that I use in the Actor Controller demo (demo_Factory) requires the character use the "Mine Bot" Animator Controller. It looks like you're trying to use the Spider AI Driver without that controller. So, you're missing the expected Unity's Animator Parameters.

    Open my "demo_Factory" scene and you'll see the "Spider Bot" GameObject uses the "Mine Bot" Animator Controller.

     
  36. Tryz

    Tryz

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

    Unfortunately, I haven't looked at Mirror.

    I had been waiting to see what Unity came out with to replace UNET, but that may be a while.

    I know some others have done networking integrations with Photon and Bolt, but I'm not sure about Mirror. I don't want to commit to anything, but I'll look at it when things calm down a bit for me.
     
  37. embbebe

    embbebe

    Joined:
    Nov 26, 2020
    Posts:
    3
    @Tryz

    Thank you for the reply.

    I am trying your demo scene.

    As you said Spider Driver script is trying to use PlayerBot Animator Controller I checked it

    with Debug.Log(mAnimator.name);

    I had this Issue as well. Jump animation was very laggy with using this driver so

    In spider controller script I disabled this line from the function:

    protected override void SetAnimatorProperties(Vector3 rInput, Vector3 rMovement, Quaternion rRotation)
    { ....
    <<<DISABLED DOWN HERE>>>
    // Perform the jump
    // mActorController.AddImpulse(transform.up * _JumpForce); // DISABLED FOR LAGGY JUMPING

    // Tell the animator what to do next
    //AND DISABLED DOWN 3 LINES
    //mAnimator.SetFloat("Speed", rInput.magnitude);
    //mAnimator.SetFloat("Direction", Mathf.Atan2(rInput.x, rInput.z) * 180.0f / 3.14159f);
    //mAnimator.SetBool("Jump", lIsInJump);
    }

    It started to jump smoothly again.

    It is wall walking with this spider driver but is it broken now without this line of code? Or may get broken in some cases?

    What can i use as a wall walking driver for Human characters? Or How can I modify spider controller script to adapt human characters?
     
    Last edited: Nov 28, 2020
  38. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    I hadn't seen that post, but I've loaded it up and A/D works correctly!

    I compared your setup with mine (the one with an empty gameobject as the player) and the difference was I didn't have an avatar assigned to my animator component. I assigned the ProtoAvatar to it and everything started working.

    I'll need to do a bit of reading on exactly what an 'avatar' is but at least now I'm off and running (to the right and the left!).

    Thank you! :)
     
    Tryz likes this.
  39. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You can use any driver for wall-walking (including the Motion Controller if you own it).

    For example, I opened the Actor Controller's "demo_Simple" scene and added some ramps:


    On the "Player", I set these properties on the Actor Controller:





    The "Orient to Ground" property will tilt the character based on the ground angle.

    The "Relative" property applied gravity based on the "down" direction of the tilted character and not the world's "down" direction.

    With that, you can use any driver for wall-walking.
     
  40. PiterQ70

    PiterQ70

    Joined:
    Mar 3, 2015
    Posts:
    82
    Hi. There is some tutorial documentation how to setup new Input System ??
     
  41. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
  42. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    @Tryz - it just dawned on me that maybe I'm approaching this the wrong way.

    If the player will be controlled in the first person would I be better off simply using your Actor Controller rather than MC since I have no need for animations in this view?

    The enemies could still use MC (since the player would see them moving about and animating) but I'm thinking for a highly responsive player controller where animations are unnecessary I probably have no need for all the extras that come with MC.

    Does this seem reasonable?
     
  43. FargleBargle

    FargleBargle

    Joined:
    Oct 15, 2011
    Posts:
    774
    I've been using trigger colliders to activate the crouch/sneak motion for quite some time, but the script I use to do this doesn't work when my player uses the Sneak_v2 motion. He goes into the motion as expected when he enters the trigger, but won't return from it when he leaves. The old Sneak motion still works, but I'd like to update to the new version before the old one disappears or stops working due to future updates.

    One weird wrinkle is that this only seems to affect my player - I can add Sneak_v2 to the PlayerBot in a demo scene, and it works completely fine. I'm at a loss how to troubleshoot this further - my player has a lot of other added motions that I don't want to lose or have to re-create from scratch, so simply replacing his controller with the one from the PlayerBot isn't an option. I've tried deleting and re-creating the Sneak_v2 motion on my player, using the same procedures and settings as the PlayerBot, but it doesn't change anything. Is there anything else - outside the Sneak_v2 state machine itself - that might make it work on one player but not another?

    Here's my script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using com.ootii.Actors;
    5. using com.ootii.Actors.AnimationControllers;
    6.  
    7. public class TriggeredCrouch : MonoBehaviour
    8. {
    9.     public string motionName = "Sneak";
    10.     private GameObject myPlayer;
    11.     private MotionController m_motionController;
    12.     private ActorController m_ActorController;
    13.     private MotionControllerMotion lMotion;
    14.     private int motionLayer = 0;
    15.     private bool triggered = false;
    16.     private bool crouchActive = false;
    17.  
    18.     void Start()
    19.     {
    20.         StartCoroutine (GetPlayer());
    21.     }
    22.  
    23.     public IEnumerator GetPlayer()
    24.     {
    25.         myPlayer = GameObject.FindWithTag("Player");
    26.         yield return new WaitForSeconds (0.1f);
    27.         m_motionController = myPlayer.gameObject.GetComponent<MotionController>();
    28.         m_ActorController = myPlayer.gameObject.GetComponent<ActorController>();
    29.     }
    30.     public void OnTriggerEnter(Collider other)
    31.     {
    32.         if (other.tag == "Player")
    33.         {
    34.             triggered = true;
    35.         }
    36.     }
    37.     public void OnTriggerExit(Collider other)
    38.     {
    39.         if (other.tag == "Player")
    40.         {
    41.             triggered = false;
    42.         }
    43.     }
    44.     void Update()
    45.     {
    46.         if (triggered && !crouchActive)
    47.         {
    48.             lMotion = m_motionController.GetMotion(motionLayer, motionName);
    49.             m_motionController.ActivateMotion(lMotion);
    50.             crouchActive = true;
    51.         }
    52.  
    53.         if (!triggered && crouchActive)
    54.         {
    55.             lMotion = m_motionController.GetMotion(motionLayer, motionName);
    56.             lMotion.Deactivate();
    57.             m_ActorController.State.Stance = EnumControllerStance.TRAVERSAL;
    58.             crouchActive = false;
    59.         }
    60.     }
    61. }
    62.  

    and here's how it works with PlayerBot using Sneak_v2, and with my player using v2 vs the original:

     
  44. dmenefee

    dmenefee

    Joined:
    Oct 14, 2019
    Posts:
    142
    Hi folks

    edit: I believe I’ll need to write a Motion to handle turning in place; I had misunderstood what I was seeing in the animator state machine...

    I use Opsive Behavior Designer to control my AIs, and am designing a 'stop to converse' Action. After a few false starts, I think I have a good solution, but it's not working; I'm sure my setup is at fault. Anyway, I'm attaching the code. I trigger the BasicIdleFocus motion, supplying a GameObject as the focus. However, no animation occurs; the AI turns as if on a turntable. I'd appreciate any hints. Thanks!
    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using com.ootii.Actors.AnimationControllers;
    6. using BehaviorDesigner.Runtime;
    7. using BehaviorDesigner.Runtime.Tasks;
    8.  
    9. namespace TLE
    10. {
    11.     [TaskName("Turn Toward")]
    12.     [TaskCategory("TLE")]
    13.     [TaskDescription("Causes the AI to turn toward the target")]
    14.     public class TurnTowardMC : Action
    15.     {
    16.         [UnityEngine.Tooltip("The target to turn toward")]
    17.         public SharedGameObject m_turnTarget;
    18.  
    19.         private MotionController m_motionController = null;
    20.  
    21.         private BasicIdleFocus m_motion = null;
    22.  
    23.         private bool m_started = false;
    24.  
    25.         private bool m_isActive = false;
    26.  
    27.         public override void OnAwake()
    28.         {
    29.             base.OnAwake();
    30.             GameObject gameObject = GetDefaultGameObject(null);
    31.             m_motionController = gameObject.GetComponentInParent<MotionController>();
    32.  
    33.             //mMotionController = agent as MotionController;
    34.             //if (mMotionController == null) { return "MotionController not set."; }
    35.  
    36.             m_motion = m_motionController.GetMotion<BasicIdleFocus>(0, true);
    37.             if (m_motion != null && m_motionController != null)
    38.             {
    39.                 m_started = true;
    40.                 return;
    41.             }
    42.             if (m_motion == null)
    43.             {
    44.                 Debug.LogError("Motion IdleFocus not found");
    45.             }
    46.             if (m_motionController == null)
    47.             {
    48.                 Debug.LogError("Motion Controller not found");
    49.             }
    50.         }
    51.  
    52.         public override void OnStart()
    53.         {
    54.             base.OnStart();
    55.  
    56.             if (m_started)
    57.             {
    58.                 m_isActive = m_motion.IsActive;
    59.                 if (m_turnTarget.Value != null)
    60.                 {
    61.                     m_motion.Target = m_turnTarget.Value;
    62.                     if (!m_isActive && !m_motion.QueueActivation)
    63.                     {
    64.                         m_motionController.ActivateMotion(m_motion);
    65.                     }
    66.                 }
    67.                 else
    68.                 {
    69.                     Debug.LogError("Target not set");
    70.                 }
    71.             }
    72.         }
    73.  
    74.         public override TaskStatus OnUpdate()
    75.         {
    76.             if (m_started)
    77.             {
    78.                 // Determine if we're active yet. This allows us to test if the
    79.                 // motion has even started
    80.                 if (!m_isActive && m_motion.IsActive)
    81.                 {
    82.                     m_isActive = true;
    83.                 }
    84.  
    85.                 if (m_isActive && !m_motion.IsActive)
    86.                 {
    87.                     m_isActive = false;
    88.                     return TaskStatus.Success;
    89.                 }
    90.                 return TaskStatus.Running;
    91.             } else
    92.             {
    93.                 return TaskStatus.Failure;
    94.             }
    95.         }
    96.  
    97.         public override void OnEnd()
    98.         {
    99.             base.OnEnd();
    100.             if (m_started)
    101.             {
    102.                 m_isActive = false;
    103.                 m_motion.Target = null;
    104.             }
    105.         }
    106.     }
    107. }
    108.  
     
    Last edited: Dec 21, 2020
  45. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845

    Most of it, is the same for Mirror.... also there are tons of tuts for mirror all over, that will work for Motion Controller. I personally retired from client, contractor after 28 years, but I still lurk around, since I'm still using Unity for the kids home schooling stuff. and been working with some other stuff to possible sell so i'm back to using some of MC again. it worked really well for some mobile games I sold and worked on for clients. we used Unet, Photon, Pun, Bolt and even some used Mirror before I retired.... Right now i'm messing with My own controller, with parts of MC, using TNET.. I even use TNet in Unreal, the server parts anyways. So, my point, most are the same. Just be sure to sync and you are good to go, some good tuts out there for mirror, some examples.
     
  46. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
  47. fero_gg

    fero_gg

    Joined:
    Sep 9, 2019
    Posts:
    6
    Hi I wondered if you can help I have the motion, camera and shooter controls, they are great and I've been having a play but I would like the strafe motions to only activate when armed otherwise default to walk/run/pivot.

    I have got the walk/run/pivot working on the shooter demo if I tick "activate with target" on the strafe motion but that's not quite what I want (and anyway it doesn't active when I equip a weapon or aim still). If that is not ticked then it ALWAYS uses strafe whether armed or not and despite the walk/run/pivot being priority 7.

    With the walk/run/strafe set to 15 which i read was the armed state, and also is the state on the pistol and rifle, it just won't strafe whether armed or not. I just need it to know if a weapon is active then use the strafe otherwise default back to the pivot. What am I missing here?

    On top of this when aiming with the camera controller "use targeting" zoom, any direction pressed (left/right/back/forward) just makes the character walk straight forward always which is I guess a separate issue?
    motions.png
     
  48. boysenberry

    boysenberry

    Joined:
    Jul 28, 2014
    Posts:
    365
    [Cross Posted In The Actor Controller Forum]
    Hello,

    I am experiencing odd behavior with MC (2.810), Unity (2019.4.16f1) and UMA (2.10.1).
    When I start my scene the Player begins to slide automatically even though I have sliding turned off in the Actor Controller. The only way I can get it to stop is to toggle the Orient to Ground setting (with Relative Gravity off) on and off again.
    I am sure there is something else I could do to prevent needing to do that, but I am not sure what it is.
    Does anyone know?

    TIA,
    Boysie
     
  49. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    There is a video on the youtube channel where strafe is being set when aiming with the bow and arrow. A similar approach could be used for shooting?
     
  50. fero_gg

    fero_gg

    Joined:
    Sep 9, 2019
    Posts:
    6
    Hi thanks, I did have a look but it doesn't go in to detail or show the character moving without the bow equipped (so it may always be strafing I'm not sure?)

    Basically I have it now so it's 99% nice, its free 3rd person movement by default, then equipping a gun it changes to the gun animations but still free movement, when aiming with the camera aim it is then locked into only moving forwards whatever direction you press... I presume because it's locked to move with the camera. It's OK but ideally I'd still want it so you can strafe left/right/back/forward when you are in the camera aim state, is that possible?