Search Unity

Motion Controller

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

  1. rubble1

    rubble1

    Joined:
    Apr 25, 2010
    Posts:
    79
    From the Inventory, using GetItemPropertyValue , is there a way to specifically refer to the item's position and rotation as it appears on the basic inventory component?

    And also, is there a way to fire off an event when specific weapons are equipped (rather than just general)?
     
    Last edited: Jan 21, 2019
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    The GetItemPropertyValue doesn't return position or rotation out of the box, but you could adjust it for your needs. The function takes a string for the property name and returns any value you program.

    The event doesn't fire per weapon because there could be an unlimited number of weapons across all the users. So tap into the general ''item equipped' event and test for the item you want. The IMessage argument will give you that information. The easiest way to do that is to look at a break point while running and you can see the contents of the IMessage. Then, program your handler for that.
     
    rubble1 likes this.
  3. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602


    Hi Tim glad to hear everything is working, in 2018. I'm still on 2017.4 for our new game. ( I wanted to thank you for making some nice assets, you made it possible, we sold our last game, to an investor. for Android, he is releasing on IOS. Thanks for making it possible for smaller companies and even one and two man teams to finish there games! Sadly we aren't using for our new Desk top game but we are using CC for it. Anyways, thinking of making another mobile game, to either release or sell. :) Lucky for you when I sell, we make sure they buy licenses to your tools that we use. anyways, I will be back around again, in the coming months. to begin another mobile game. /cheers. Congrats on your new job.. and glad to see you have a helper now, Teagan's Dad knows Motion Controller prolly better than anyone. good choice. to watch your baby while you been busy :)
    Just wanted to see how things are going here.
     
    Tryz likes this.
  4. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602

    This for sure is IK related. If you are not able to understand, setting up your own rig or IK, for sure get Final IK.. I'm a 3d modeler as well I can animate, Rig, skin. So for aiming its super important to have a proper IK set up. I use FK, IK set ups . When working with weapons, you need to make sure you have an extra bone, which needs to be lined up so that the weapon can be attached. typically you want the weapon to follow the hand rotation and the arm. looks like the IK is being allowed to rotate. in the wrong axis. possible. or its a bone constraint issue.

    So for example, have that extra bone, driving that right arm or left depending which one you are using. as the main. but also there could be a few of other issues, hard to say for 100% sure. but for sure its a IK related issue.. So really that is your two choices, get Final IK, or take a look at the IK set up in Blender...by the way, be careful with switching, between, 3d programs.... I tend to see issues with IK, when I switch between Maya, Modo, or Modo Blender etc.. MAX TO Maya not so much, but some of the others.... I tend to see issues. Also there is a good asset for animations, for Unity as well, as I see some times, animations as well, getting screwed up ever so slighty when bringing into Unity from Maya, or Modo.... Unreal this don't happen. so also take a look at U Motion. Good Luck
     
    stuartdn and Tryz like this.
  5. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Thanks @recon0303 . Definitely a crazy time.

    No doubt @TeagansDad rocks. As I'm getting into a rythm here things will get back to normal and you will see me back here more. :)
     
    StayUpLate likes this.
  6. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602

    I hear you there, we been working hard on a new Unity game, and I also started a new partner ship with someone I know from a studio I worked with, for an Unreal game, so its been nuts. that is for sure. haha.
     
    Tryz likes this.
  7. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    141
    I am using Motion Controller, A* Pathfinding Project and Behavior Designer. I followed the tutorial for NPCs with the Ootii Motion Controller, but I am experiencing issues.

    Here is a GIF of the issue. The character starts moving without animating (sliding along), as if there is low acceleration in his animation. When he reaches his destination, it takes time for his walk animation to stop, so he walks in place. Also, no matter the speed I set, the character will not Run:

    https://gyazo.com/27420cce8c6d9570e390906b37c3c228

    You'll notice in the GIF that he starts out starting/stopping incorrectly, then starts working mostly correct, and then stops working again. It looks to me that the issue occurs when he is in a stopped state (stopping animation when stopping movement, starting animation when starting movement).

    I am using the "Walk Run Strafe" motion. I haven't changed the animator sub state created by Motion Controller, nor touched the Blend.

    Here are my Motion Controller/Actor settings:




    Walk Run Strafe motion:



    Here is my A* setting:



    Here is my Behavior Designer "Patrol" node:




    What would be causing my character to (1) not immediately animate when movement is started, (2) not stop animating as soon as the movement is stopped and (3) never switch to a Run animation when moving quickly?

    Thank you -
     
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @Appminis ,

    This is exactly what I talk about in this video:


    The short answer is that you're not using root motion. So, the character's movement and animations won't be in sync.

    You're using BD to tell A* and that does all the movement. Nothing to do with animations.

    The MC is watching for transform movement because you have "Use Transform" checked. However, I don't start animating because you moved 1 millimeter. There's a threshold that I'm waiting for.

    You can also change the property settings to help get the animation faster too. For example, reduce the "Smoothing Samples".

    Check out the video for more options.
     
    hopeful likes this.
  9. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Hi Tim, I'm still having the issue for players in europe not able to use camera controller without setting their regions into en-us. (with .Net 4.x equivalent)
    The camera will not follow the character and will always float in mid air when they enter the scene.
    Is there a fix or work around for this issue? Caused a lot complains on my game now.

    Edit: Just ran a test on my pc: I changed my windows' location to Neatherlands, language to Dutch(Neatherland) and changed the float separator rules to Neatherland too.
    And even in unity editor, the camera controller and the actor controller can not work correctly. Hope this can let you debug the system in your end.
    And I found my own camera controlling scripts and other character controlling assets works fine in this situation, so this definately cannot be on Unity's side, you'll have to make it compatible with .Net 4.x equivalent yourself. And I think this is neccessary for Unity 2018.3 just default enabled .Net 4.x so this great asset will not be able to be used in a large region of the world.
     
    Last edited: Jan 31, 2019
  10. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    141
    So it sounds like to use root motion I'd need a custom driver?
    Any chance you have a driver for A* or advice for how to do that, for a more beginner programmer?
     
  11. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802

    Would you be able to try out a fix for me? I'm at work right now, so I can't test it out myself at the moment. :)

    Edit the file JSONSerializer.cs, located in Assets\ootii\Assets\Framework_v1\Code\Data\Serializers\

    Add the statement
    using System.Globalization
    to the "using" statements at the top of the file.

    Change these two lines of code in the function
    private static string SerializeValue(object rValue)
    :

    From:
    Code (CSharp):
    1. 422: lJSON.Append(((int)rValue).ToString());
    2. 427: lJSON.Append(((float)rValue).ToString("G8"));
    To:
    Code (CSharp):
    1. 422: lJSON.Append(((int)rValue).ToString(CultureInfo.InvariantCulture));
    2. 427: lJSON.Append(((float)rValue).ToString("G8", CultureInfo.InvariantCulture));
    Then edit the file SimpleJSON.cs, located in Assets\ootii\Assets\Framework_v1\Code\Utilities\

    Add the statement
    using System.Globalization
    to the "using" statements at the top of the file.

    Starting around line 107, replace the existing AsInt, AsFloat, and AsDouble properties with this:
    Code (CSharp):
    1. public virtual int AsInt
    2.         {
    3.             get
    4.             {
    5.                 int v = 0;
    6.                 if (int.TryParse(Value, out v))
    7.                     return v;
    8.                 return 0;
    9.             }
    10.             set
    11.             {
    12.                 Value = value.ToString(CultureInfo.InvariantCulture);
    13.             }
    14.         }
    15.         public virtual float AsFloat
    16.         {
    17.             get
    18.             {
    19.                 if (Value.Length > 0 && Value.IndexOf("-") >= 0 && Value.IndexOf("E+38") >= 0) { return float.MinValue; }
    20.                 if (Value.Length > 0 && Value.IndexOf("-")  < 0 && Value.IndexOf("E+38") >= 0) { return float.MaxValue; }
    21.  
    22.                 float v = 0.0f;
    23.                 if (float.TryParse(Value, out v))
    24.                     return v;
    25.                 return 0.0f;
    26.             }
    27.             set
    28.             {
    29.                 Value = value.ToString(CultureInfo.InvariantCulture);
    30.             }
    31.         }
    32.         public virtual double AsDouble
    33.         {
    34.             get
    35.             {
    36.                 double v = 0.0;
    37.                 if (double.TryParse(Value, out v))
    38.                     return v;
    39.                 return 0.0;
    40.             }
    41.             set
    42.             {
    43.                 Value = value.ToString(CultureInfo.InvariantCulture);
    44.             }
    45.         }

    The only actual change in all of this is adding CultureInfo.InvariantCulture as the IFormatProvider parameter in the .ToString() methods for numeric types.

    I think that this should work for the time being. Please let me know if it works for you.

    EDIT: You will probably have to re-edit all of the incorrect numeric values after applying these fixes, as the incorrect values have already been serialized.
     
    Last edited: Jan 31, 2019
    Tryz likes this.
  12. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Hi, Thanks for the reply!
    I've located this script before and tried to force all parses related to float using en-us culture (includes Vector2,3,4 FromString methods and float/double's TryParse methods in the JSON script.)
    It works for me, but I guess you can come up with better solutions :)
     
  13. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    I'm guessing you're using the .Net 4.x. That seemed to change how localization works and it ignores the normal "System.Threading.Thread.CurrentThread.CurrentUICulture" setting that used to work.

    That's cool that @TeagansDad 's solution worked. I messed with this a while back and never found a clean solution. If this works, I'll get it into the base code (after testing all the other versions of Unity).
     
    recon0303 likes this.
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Unfortunately, I don't own A*.

    If you look at my NavMeshInputSource.cs, you should be able to find the code that uses Unity's Nav Mesh and replace it with A*'s code. For example, the NavMeshInputSource.cs uses Unity's Nav Mesh to get a path. Then, it uses Unity's Nav Mesh Agent to get direction and speed. You'd have to figure out how to get the path from A* and how A*'s agent determines direction and speed. Then you'd change the code sections as needed.

    I know that sounds a bit tricky, but once you get into it I think it should be pretty straight forward. You're just replacing the Unity approach with the A* approach.
     
  15. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    You can simply set your Windows' region into Netherlands and the language, the decimal separator culture settings all into Netherlands. Then you can see the issue, so can test different methods and see if they can fix it.
    I used my own methods to fix the issue, so far they seem to work correctly:
    I added a line to create a CultureInfo from "en-us" and pass it into each Parse method that is deserializing a float, decimal or double. Since my country region uses the same number culture as US, I have no issue with direct serializing data. But some European countries users of ootii products with .Net 4.x may find their built game unable to be run outside of European. And all ootii default data would be insane in their pc.

    PS: I don't see @TeagansDad 's methods change the culture on the Parse method, is the invariantCulture able to be parsed into every local culture without passing any culture settings into the Parse method?
     
    Tryz likes this.
  16. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802
    The Parse() and TryParse() methods should actually specify CultureInfo.InvariantCulture as well. That was an oversight on my part, as I was trying to answer quickly while at work.

    SimpleJSON.cs includes oce each of int.TryParse(), float.TryParse(), and double.TryParse() which should all specify CultureInfo.InvariantCulture. JSONSerializer.cs has four float.TryParse() statements and one int.TryParse().
     
    Tryz likes this.
  17. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Thanks for the info!
    In the CameraMotor.cs I found a method called SerializeMotor directly turn data to string in it. It does not use the AsInt / AsFloat methods from SimpleJSON to serialize but uses them to deserialize data.

    Code (CSharp):
    1. public virtual string SerializeMotor()
    2.         {          
    3.             if (_Type.Length == 0) { _Type = this.GetType().AssemblyQualifiedName; }          
    4.  
    5.             StringBuilder lStringBuilder = new StringBuilder();
    6.             lStringBuilder.Append("{");
    7.  
    8.             // These four properties are important from the base MotionControllerMotion
    9.             lStringBuilder.Append(", \"Type\" : \"" + _Type + "\"");
    10.             lStringBuilder.Append(", \"Name\" : \"" + _Name + "\"");
    11.             lStringBuilder.Append(", \"IsEnabled\" : \"" + _IsEnabled.ToString() + "\"");
    12.             lStringBuilder.Append(", \"ActionAlias\" : \"" + _ActionAlias.ToString() + "\"");
    13.             lStringBuilder.Append(", \"UseRigAnchor\" : \"" + _UseRigAnchor.ToString() + "\"");
    14.             lStringBuilder.Append(", \"AnchorIndex\" : \"" + _AnchorIndex.ToString() + "\"");
    15.             lStringBuilder.Append(", \"AnchorOffset\" : \"" + _AnchorOffset.ToString("G8") + "\"");
    16.             lStringBuilder.Append(", \"Offset\" : \"" + _Offset.ToString("G8") + "\"");
    17.             lStringBuilder.Append(", \"Distance\" : \"" + Distance.ToString("f5") + "\"");
    18.             lStringBuilder.Append(", \"MaxDistance\" : \"" + MaxDistance.ToString("f5") + "\"");
    19.             lStringBuilder.Append(", \"IsCollisionEnabled\" : \"" + _IsCollisionEnabled.ToString() + "\"");
    20.             lStringBuilder.Append(", \"IsFadingEnabled\" : \"" + _IsFadingEnabled.ToString() + "\"");
    21.             lStringBuilder.Append(", \"SpecifyFadeRenderers\" : \"" + _SpecifyFadeRenderers.ToString() + "\"");
    22.             lStringBuilder.Append(", \"FadeTransformIndexes\" : \"" + string.Join(",", _FadeTransformIndexes.Select(n => n.ToString()).ToArray()) + "\"");
    23.  
    24.             // Cycle through all the properties.
    25.             // Unfortunately Binding flags don't seem to be working. So,
    26.             // we need to ensure we don't include base properties
    27.             PropertyInfo[] lBaseProperties = typeof(CameraMotor).GetProperties();
    28.             PropertyInfo[] lProperties = this.GetType().GetProperties();
    29.             foreach (PropertyInfo lProperty in lProperties)
    30.             {
    31.                 if (!lProperty.CanWrite) { continue; }
    32.  
    33.                 bool lAdd = true;
    34.                 for (int i = 0; i < lBaseProperties.Length; i++)
    35.                 {
    36.                     if (lProperty.Name == lBaseProperties[i].Name)
    37.                     {
    38.                         lAdd = false;
    39.                         break;
    40.                     }
    41.                 }
    42.  
    43.                 if (!lAdd || lProperty.GetValue(this, null) == null) { continue; }
    44.  
    45.                 object lValue = lProperty.GetValue(this, null);
    46.                 if (lProperty.PropertyType == typeof(Vector2))
    47.                 {
    48.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + ((Vector2)lValue).ToString("G8") + "\"");
    49.                 }
    50.                 else if (lProperty.PropertyType == typeof(Vector3))
    51.                 {
    52.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + ((Vector3)lValue).ToString("G8") + "\"");
    53.                 }
    54.                 else if (lProperty.PropertyType == typeof(Vector4))
    55.                 {
    56.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + ((Vector4)lValue).ToString("G8") + "\"");
    57.                 }
    58.                 else if (lProperty.PropertyType == typeof(Quaternion))
    59.                 {
    60.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + ((Quaternion)lValue).ToString("G8") + "\"");
    61.                 }
    62.                 else if (lProperty.PropertyType == typeof(Transform))
    63.                 {
    64.                     // We use the _StoredTransformIndex for serialization
    65.                 }
    66.                 else if (lProperty.PropertyType == typeof(List<int>))
    67.                 {
    68.                     List<int> lList = lValue as List<int>;
    69.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + string.Join(",", lList.Select(n => n.ToString()).ToArray()) + "\"");
    70.                 }
    71.                 else if (lProperty.PropertyType == typeof(AnimationCurve))
    72.                 {
    73.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"");
    74.  
    75.                     AnimationCurve lCurve = lValue as AnimationCurve;
    76.                     for (int i = 0; i < lCurve.keys.Length; i++)
    77.                     {
    78.                         Keyframe lKey = lCurve.keys[i];
    79.                         lStringBuilder.Append(lKey.time.ToString("f5") + "|" + lKey.value.ToString("f5") + "|" + lKey.tangentMode.ToString() + "|" + lKey.inTangent.ToString("f5") + "|" + lKey.outTangent.ToString("f5"));
    80.  
    81.                         if (i < lCurve.keys.Length - 1) { lStringBuilder.Append(";"); }
    82.                     }
    83.  
    84.                     lStringBuilder.Append("\"");
    85.                 }
    86.                 else
    87.                 {
    88.                     lStringBuilder.Append(", \"" + lProperty.Name + "\" : \"" + lValue.ToString() + "\"");
    89.                 }
    90.             }
    91.  
    92.             lStringBuilder.Append("}");
    93.  
    94.             return lStringBuilder.ToString();
    95.         }
     
    recon0303 and Tryz like this.
  18. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Thanks.

    With Mono's .Net 4.x not following the .Net localization the way previous versions did, it left a mess. If this solution is working, I'll have to go through and make the updates in several places.

    Late last year I did change my computer to French in order to work through this. It just made it impossible to work since dialogs and menus... turned into a language I can't read. :D
     
    recon0303 likes this.
  19. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802
    @Harekelas Now I'm remembering... Yeah, there are a couple of different approaches to serialization in the code base. I had to update all of the serialization code when reorganizing things to support assembly definition files (as the types would now be located in a different assembly than before). Because it's not my code base, I kept a list of files that I modified and ensured that I commented every change I made in the source files. I'll go back to those notes and see if there are any other spots that haven't been mentioned yet.
     
    Last edited: Feb 3, 2019
    Tryz likes this.
  20. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602

    yes sadly it did make a mess, its driving many people crazy haha we had to make fixes to a lot of our tools we made as well. I had a list I made up for any asset I use like MC. ( not your fault) of course , but ya I hate when they make these changes. it makes it a nightmare for everyone. lol

    ROFL, French eh? fun times ..

    I hope all is well, and your settled :)
     
    Tryz likes this.
  21. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602


    since your using A* if I remember right, its been a little bit since I added mine for A* but I believe what you will need is in the class AIPath do a search for it. That should help. if I remember right ( don't hold it to me, but I believe that was the class .
     
    Tryz likes this.
  22. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    100
    Yea any of the AI scripts in the A* library would be perfect for writing up a Source/Driver, I do have A* and am currently just using transform for all my testing but i do need to come up with the A* driver at some stage for more control.
    Figure i might as well put the ragdoll damage system on hold and do this, so I will post my result up here when i'm done for other users to reference (or improve!).
     
    Last edited: Feb 3, 2019
    Tryz likes this.
  23. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802
    @Harekelas, @Tryz

    These methods don't use the JSONSerializer and also need to be updated with CultureInfo.InvariantCulture:

    BodyShape.Serialize()
    CameraMotor.SerializeMotor()
    CameraMotor.DeserializeMotor()
    MotionControllerMotion.SerializeMotion()
    MotionControllerMotion.DeserializeMotion()
     
  24. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    Thank you very much!
     
  25. HiddenFace

    HiddenFace

    Joined:
    Feb 13, 2016
    Posts:
    12
    Still a great asset ^^
    When do you release the next upadte?
     
  26. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Thanks. :)

    Probably in the next two weeks. I've started a new job and its been crazy. I just need to get some breathing room. :)
     
  27. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    100
    Hi Appminis,

    Here's what i've come up with so far. Its working in a pretty simple way with some big caveats like RVO and Path Modifiers dont work. This is a simple port of the Nav Mesh Input Source to work with A* but it is not currently taking full advantage of the A* framework in any way haha. It needs a fair bit of refinement but it should get you started, there is also some interesting stuff on the A* Pathfinding Project webpage so improving this is possible with a bit more time and effort. Feel free to message me with any questions, All the best! :)

    Subliminum.

    A_STARInputSourceEditor should go in ootii\Editor\MotionController\Input\
    A_STARInputSource should go in ootii\Assets\MotionController\Code\Input\
     

    Attached Files:

  28. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Subliminum likes this.
  29. stuartdn

    stuartdn

    Joined:
    Feb 3, 2018
    Posts:
    14
    Hi @recon0303

    Sorry for the late response I've been preparing to move house (seems like the season for it). Thanks for your suggestions. I tried a cheaper IK solution called SimpleIK to try and force the arms into the positions I wanted but didn't have much luck. As I'm working on a Game Design portfolio piece (will share some screenshots below) I think I will stick with the arms as is and focus on elements more relevant to game play. Then come back to this at the end if time.

    I've now encountered two further issues I was hoping people could help me with.

    1) When I try using Basic Animation along with the Shooter Pack triggering the Interaction causes the character to walk forward and then bump into the door and continue walking with me being unable to regain control. Does any one have any idea what might be causing this?

    2) I would like to implement simple melee attacks (like The Last of Us). I've figured out how to damage enemies using Animation events and a colliders on the fist of the Punch movement provided with Ootii. However I don't know how to add my own melee animations. Is there guidance anywhere online on how I can do this? I could buy the Sword pack but it'd be overkill for my needs.

    Sorry if these sound dumb or have been answered elsewhere.

    Cheers,

    Stuart
     
    Last edited: Feb 6, 2019
  30. stuartdn

    stuartdn

    Joined:
    Feb 3, 2018
    Posts:
    14
    Hi All,

    So that you can see my questions are feeding into something worthwhile here are a few screenshots showing mechanics for a Game Design portfolio level I'm working on which is intended as a 'The Last of Us' style third person actioner with dinosaurs.

    For this I've managed to integrate Ootii with Emerald AI and Tactical Shooter AI. I've made is so that my player is able to pick up weapons and health packs (which can be used later). They can also aim over shoulder with the player able to toggle between shoulders.

    When the players are injured the screen desaturates and turns red.

    I've got most of the mechanics sorted so my next job is to design the level itself and finish up the UI.

    Cheers,

    Stuart

    Title Screen.jpg Collect Pistol.jpg Running from Raptors.jpg
    Raptor Hunting.jpg
    Low Health.jpg
     
    recon0303, Subliminum and TeagansDad like this.
  31. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    141
    Thanks! I'll give this a try! :)
     
    Subliminum and TeagansDad like this.
  32. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602


    Well not sure if you want to, or want to try, but you can set up, IK, your self in a 3d program. of sort. I always set up FK, and IK, when ever I make characters, NPC and such. and reuse the rig. for other characters. I make a Male and Female Rig, and possible a child, depending on the game...Its crazy when I need animals, and robots etc, like my current game, we have like 9 rigs. lol but I tend to make IK and FK mostly but NPC I will just reuse a rig, or I may make a genric one for performance. if I need to. but setting up IK isn't really that bad in Maya. Blender I would think its not bad either... but I use Maya so not sure.
     
    stuartdn likes this.
  33. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602


    Looks good, show some videos of it:) that would be great
     
    Tryz, stuartdn and Subliminum like this.
  34. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    100
    Surely you only use that for animating the rigs in Maya. How do you use the extra bones during runtime, if you dont mind me asking out of curiosity? Ive done rigging for IK/FK in blender but only really use it in there for pose testing and animation. When i export for unity these bones are removed for efficiency with the Humanoid animation system.
     
  35. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,602

    bones get removed, for different reasons, so for example if its a NPC, who don't do much, I will remove IK, FK , extra bones and so forth, but I will reuse rigs across the board for work flow and time. You always want to reuse rigs as much as you can, you can always remove what you don't need or want, for different characters...I see some games use the same rig through out....I don't agree with it as I see female walking like a man. looks funny due to the rig and animations being reused. so you need to be smart about it.. So you can easily remove. when you don't need. (I cant share anything related to run time.) its company stuff. but in a nut shell, just remove when is not needed.
     
    Subliminum likes this.
  36. Awesumo

    Awesumo

    Joined:
    Nov 6, 2011
    Posts:
    57
    Quick question about custom motions. If I have a character with its own animation controller and I want to use some of it's animations and also use some of the animations set up in the Humanoid controller, what is the workflow for doing this? Should I be adding things to Ootii's humanoid controller or should I be configuring motion controller to use a hybrid controller? Not looking for magic bullet, just a workflow that makes sense if using a fully rigged and animated character with MC, but also taking advantage of the add-on motion packs. Like, my fully rigged and animated character + Ootii's spell casting? I've read through the docs and I am not seeing a clear workflow for this type of thing. (though I could certainly be missing it!)
     
  37. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802
    @Awesumo - You'll want to use a single animator controller.

    All of the motions included with Motion Controller and the Motion Packs are capable of creating their own animator states on an animator controller . There's a gear button (I think it's a gear) on each motion's inspector that leads to advanced options where you can run a script to create the animator states (and also generate the script for doing so from the existing animator).

    If you use the Character Wizard to set up a character, it actually generates a brand new animator completely from scratch, which might be the best way to start, as the Humanoid one contains everything for all of the included motions, some of which you may not be using.
     
    mandisaw, hopeful and Tryz like this.
  38. Awesumo

    Awesumo

    Joined:
    Nov 6, 2011
    Posts:
    57
    Thanks TD, I'll start with the Character Wizard and work from there.
     
  39. Awesumo

    Awesumo

    Joined:
    Nov 6, 2011
    Posts:
    57
    TD's advice worked and the Character Wizard made it pretty easy to get a custom player character working with all motion packs. BUT, when I set up an NPC, using either navmesh or the demo npc_controller_v2 script, my NPC moves but no animations play, he just wanders around in a t-pose - yet combat still happens and the NPC can kill my player char - from a t-pose. When I watch the animator, it is cycling through all the correct idle/walk/combat nodes, but no animation plays. If I set a node as default the animation plays just fine. Any ideas?
     
  40. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    802
    @Awesumo - are you using the same character model as for the player or a different one? First thing that comes to mind is to check that the NPC is set to use a Humanoid rig and not Generic.
     
  41. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    I'd like to report an old bug:

    Any sub-state machine with transitions from Entry will not be able to generate correct auto-script by clicking the "Generate Mono Script" button in motion's inspector.

    The issue is due to MotionControllerMotion.cs, line 2493: in the for loop for entry transitions, there used anystateTransitions array which should be entryTransitions array.

    and line 2602: there added one more CleanName to the transition's name where already added the hash ID of the transition.

    I've fixed the issue on my end, but it's very annoying to have to change these locations over again when I updated the asset. So hope these will be fixed in the next update :)
     
    Tryz, TeagansDad and Subliminum like this.
  42. sparkwd

    sparkwd

    Joined:
    Aug 12, 2018
    Posts:
    12
    Hi @Tryz,

    I think I read somewhere that you base the speed of the the character on the animation's root motion? I was wondering what the best practice would be for determining how fast the player is currently moving? For example, if I wanted stamina to deplete when the character is running else slowly replenish when he is not. Thanks... sorry if this question has already been answered.
     
  43. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    I think you can always get the current velocity of the Actor Controller, you can check the speed in your walk run motion's update by call the mActorController.Velocity.magnitude and use this for stamina reductions.

    For me, I used my own motion for walking and running, so I defined several different gaits (float) for the character: walk(1), jog(2) and run(3). Then scale the gait smoothly according to player's input, and reduce stamina by current gait value. I let movement reduce the stamina recover speed by 50% on gait 1, 0% on gait 2 and start cost stamina about gait 2, finally reduce 10 stamina per sec when gait reaches 3.
     
    Tryz and sparkwd like this.
  44. sparkwd

    sparkwd

    Joined:
    Aug 12, 2018
    Posts:
    12
    Thanks @Harekelas, that works. My script is attached to the player game object, so I just used

    Code (CSharp):
    1. mActorController = gameObject.GetComponent<ActorController>();
    to get the actor controller component. Thanks for the help, much appreciated.
     
  45. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    743
    if you are calling this in one of the motion's scripts (inherited from ootii's MotionControllerMotion), it already cached a mActorController for you. No need to get it again.
    But you can always get this component from any monobehaviour attached to your player.
     
    sparkwd likes this.
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @sparkwd , Sorry for the delay. The weekends are when I catch up on Unity work.

    @Harekelas is exactly right (as you found). But there's more data that could be helpful too...

    The ActorController.Velocity is a short cut to the AC's State object. That State object has things like velocity, is grounded, distance from ground, ground normal, etc. Lots of info.

    Even more, there's a States array that allows you to go back in time and see what the velocity was. Just use the StateIndex property to determine the current index as the States array is a rolling array for speed.

    I hope that all makes sense. :D
     
    mandisaw and sparkwd like this.
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,225
    Hey @Harekelas , Thanks for that.

    I'll go through the comments and code. I'm happy to clean that up.

    I had hoped to do an update this weekend, but I don't think that's going to happen. Should be soon though.
     
  48. sparkwd

    sparkwd

    Joined:
    Aug 12, 2018
    Posts:
    12
    Thanks for the response @Tryz. Sounds like there are a lot of different things I can tap into. I’ll check those ideas out when I dive back into that part.

    I have another question… I know I’m missing something simple, but I’m having a hard time finding a solution, so I figured I’d just ask. Can anyone steer me in the proper direction for detecting collision between a weapon/tool I’ve equipped and another item… like a tree for example? Not for NPC combat, just regular collision detection on a Game Object with a collider. I have a tree with a collider and rigidbody but I’m not getting any feedback from a script I attached to it with OnCollisionEnter(). I’m not sure where to tap into the animation events for the “BeginFOA” string on the animation used for the axe and that’s probably what I’m missing. Thanks in advance.
     
  49. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    100
    Do you use a weapon that has a collider on it as well, and are they on matching physics layers?
    You can also use the IDamageable interface and run logic for being hit inside of a
    Code (CSharp):
    1. /// <summary>
    2.         /// Tells the implementor that it has been damaged using the message.
    3.         /// </summary>
    4.         /// <param name="rMessage">Message that defines the damage amount and type.</param>
    5.         /// <returns>Determines if the damage was applied.</returns>
    6.         bool OnDamaged(DamageMessage rMessage);
    method. For example you could make a Tree.cs which uses that interface and the OnDamaged() could run your logic for the tree being damaged in various was by the info from rMessage, which ive found quite useful.
     
    sparkwd likes this.
  50. sparkwd

    sparkwd

    Joined:
    Aug 12, 2018
    Posts:
    12
    Thanks for the response @Subliminum. Sorry about that… turns out I was trying to use
    OnCollisionEnter()
    while both object’s RigidBodys were set to isKinematic = true. To solve my issue, I just used
    OnTriggerEnter()
    instead.

    I’m not sure I follow how to use the IDamageable interface. I can see what you mean about sending the health/type parameters using a message with OnDamage(), but I’m not sure where to call it or retrieve from it. Would that work like the the Activated Event(IMessage) on the Interactable Core script?