Search Unity

Motion Controller

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

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I will, but Unity isn't planning on finishing and releasing it until Unity 2020 comes out. Once that happens, I'll integrate with it.

    It sounds like you implemented the Input Source interface methods. That would then be used to feed into all my assets.

    I don't actually ever check for key codes. I check for the Action Alias. Let's take Jump and the current Unity Input Manager and my default Unity Input Source as an example.

    In the Jump motion, there's an Action Alias to cause a jump. I default that value to "Jump":



    In the Jump motion code (line 345), you'll see where I check this:
    Code (CSharp):
    1. if (mMotionController._InputSource.IsJustPressed(_ActionAlias))
    In the UnityInputSource.cs (line 318), I have the IsJustPressed(string) function that takes the "Jump" value as a string. In this implementation, I use Unity's "UnityEngine.Input.GetButton(string)" function.

    Inside my Unity Input Source, the string "Jump" simply gets passed to Unity's Input Manager.

    Unity's Input Manager looks at the friendly name and checks the "Positive Button" that you set.


    So, I never check the KeyCode. I pass the string.

    The fact that the KeyCode definition changed in Unity shouldn't matter. In your "New Unity Input Source" implementation, you would simply replace my implementation of IsJustPressed(string) with what matches to Unity's new input solution. I'm assuming internally they have a way of tying "Jump" to a button.

    You could also write code like:
    if (rAction == "Jump") { ... }

    I hope that helps.
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Right. AutoClear needs at least three frames to work. So, the transition has to have something. It can be pretty small and if your animations support instant transitions, having a 0.05 transition should look fine.

    Once I find time, I'll have to see if there's a way to do it without any transition. Time is tight right now.
     
  3. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Hi, I am wondering whether this asset would be a good fit for me-- Can main character apply physics with its movement? So for example can it push objects by walking against them? Thanks.
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Yes, but you have to set it up.

    1. On your objects, put a RigidBody. Then, set the Layer property to some value like "No Collision".

    2. On the character, put a RigidBody. Then, check "Is Kinematic" and uncheck "Use Gravity".

    3. On the character, go to the Actor Controller (because of the Motion Controller) and set the "Collision Layers" property to NOT include the "No Collision" value you set in #1.

    Now the character will push into objects and Unity physics will push those objects out of the way.

    You just have to figure out if that's what you really want. It's good for randomly pushing garbage out of the way, but no so good for pushing something that needs control (like a grocery cart).
     
    ml785 likes this.
  5. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    The included motions look fantastic and I love the archery/magic addons.
    I have always wanted to create a 'parkour' Mario64 type platformer-- What would the process be like of creating twitch 'parkour' motions like double jumping, sliding down/jumping off walls (if said motions aren't already available)?
     
  6. Tryz

    Tryz

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

    Check out the Motion Builder Guide and this Motion Builder video.


    The video is old, but mostly still relevant.

    With things like this, think there's really two good approaches:
    1. Take is slow and start simple. Start with a simple jump and then move to double-jump.
    2. Look at my motions and steal from them.
    Be aware that my Jump is more complicated because it's a physics jump that has several stages. Start with something simple like my Idle, then Walk Run Strafe, and then look at Jump.

    Hopefully all of this helps. :)
     
    ml785 likes this.
  7. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey Keith. I'm still in Japan, but I'm trying to spend more time here on the forums.

    While I've still got more time away, I am thinking about what's next... documentation, ECS, DOTS, networking, GUI, AI, etc. Thoughts?
     
    Last edited: May 5, 2020
    rubble1 likes this.
  9. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    Your documentation is already pretty good. Sometimes its difficult to find exactly what you want because it is spread out between videos, website, and manuals but it is all there.

    Personally, I think the AI should be your next step. ECS and DOTS are just not ready yet, and your system already has good performance. A networking module would be nice for people that need it i guess. But the asset store in general is missing a really good AI solution. ICE is basically defunct, and Emerald AI is really good but just had to extend. Your systems are always excellent at being able to extend the code and modify the functionality of the asset without modifying the original code.

    I thought that a good AI system that works kind of like the Motion Controller would be a great idea. You just have a system of AI behaviors that you could plug into a system similar to the sub state machines on the motion controller. If a particular behavior, or state if you will can run then it will. Their would probably have to be a master state machine that could easily be modified but when in a particular state, the system would scan the behaviors, find the most appropriate one and then run it. Not sure on the performance of it but it sounds like it would work.

    Not really sure what you would do with the GUI other than create something for the motion controller and all of its modules? Inventory, etc?
     
    Tryz likes this.
  10. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thanks for the feedback.

    I've been playing with ECS and their NetCode for multiplayer, but it certainly doesn't feel baked at all. So, I'm hesitant spending what little time I have in building something real out of it (yet).

    Sad to hear about ICE. I'll have to start tinkering again (when I have time). :)
     
  11. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957

    Hi Dave,

    Sorry for the delayed response!

    I do have a collection of integration scripts for ORK Framework that I've been working on (inconsistently) for a while. It's a fairly complex integration and I'm still in the process of pulling the pieces from 3 or 4 different approaches into a more consistent and unified whole. I haven't really touched it in a couple of months, however, as other things have been demanding my attention.

    The key concept to integrating the stats and calculations from the ORK side with the animated actions on the ootii side is getting the (ORK) class that inherits from BaseAction which represents the ORK Ability to be used and then calling the Calculate() method at the appropriate time. For melee/ranged attacks, spells, etc I don't use ORK Damage Dealers, as I find its collision detection to be too coarse-grained for my liking. So I use all of the default collision detection logic in the ootii motions and then use a custom DamagedReactor to call the BaseAction.Calculate() method, which will apply damage to the appropriate ORK Status Value, apply Status Effects, etc (instead of using a "Health" attribute on BasicAttributes).

    I've also got a set of custom ORK Event Nodes that are used to activate a custom Motion (on Motion Controller) and register a callback function. This is so that the Motion can tell the ORK Event Node that called it when it has completed (rather than building a clunky Wait loop in ORK that keeps checking to see if the motion is still active).

    My inventory integration used to work, but there have been some breaking changes to the ORK inventory API over the past year and I haven't gotten around to rebuilding it yet. It started as a copy of BasicInventory's logic where I extended the classes to contain references to the ORK inventory items. Then I extracted the core logic from ORK's EquipmentViewer (the code that detects when there has been a change in what is equipped to an Equipment Part) so that equipping and unequipping items on the ORK side would dynamically rebuild the Items and Weapon Sets collections on the custom inventory component. So equipping a sword and shield in ORK would rebuild Weapon Set 0 on the custom inventory component, and the player can draw or stow the weapons in sync with the animations. I didn't want ORK to handle mounting or removing a weapon from the character's hand, as I wanted to show weapons stored on the character's hip or back when they were "equipped" in the UI but have not been drawn.

    Anyway, that's the approach that I took. I will try and get back to getting my integration scripts into a state where I feel more comfortable sharing them (as they're a bit of a confusing mess at the moment), but that probably won't be for a few more weeks.
     
    Tryz likes this.
  12. Smellydave

    Smellydave

    Joined:
    Sep 20, 2013
    Posts:
    6
    Hey @TeagansDad, thank you for such a detailed reply :) - I have just started playing with the inventory but really look forward to seeing your integrations as I am very much a newbie and seem to learn loads any time I look at someone elses stuff and inevitably end up changing (copying) everything!!

    thanks again

    Dave
     
  13. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey guys. i have a motion where i need the character to stand exactly behind another NPC. I have attempted to do the following:

    (Activate Method)

    Code (CSharp):
    1.         mMotionController.transform.position = _target.position - _target.forward * 0.5f;
    2.  
    3.         mMotionController.SetAnimatorMotionPhase(mMotionLayer._AnimatorLayerIndex, PHASE_START, true);
    4.         mMotionController._Transform.rotation = Quaternion.LookRotation(Vector3.Normalize(mMotionController.transform.position - _target.position));
    However, it doesn't seem to work

    upload_2020-5-7_15-59-24.png


    I have also tried transform.lookat but again no results.

    Can anyone help me out? :)
     
  14. Tryz

    Tryz

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

    You can't modify the transform directly because the Actor Controller is doing that using info from the Motion Controller. So, you need to tell the Actor Controller to change the position and rotation directly.

    Check out page 7 & 8 of the AC's User Guide. It gives you the functions and some example code.

    Another approach is to have the MC make these calls over time using a coroutine. You would call something like this:
    Code (CSharp):
    1. mMotionController.StartCoroutine(mMotionController.MoveAndRotateTo(Vector3.zero, mEndRotation, 0.7f, true, false, true));
    This will have the character move and rotate over time (using the AC's functions).
     
  15. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    @Tryz Thank you so much for the response. now even though I can rotate the player I cant seem to get the rotation right.

    Do you have any advice if I want the character directly behind the NPC looking in the same direction
     
  16. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    Hey, I'm getting a large performance decrease from the Actor Controller when I add a bunch of NPC actors.
    I wanted to ask what is the best setup for performance for NavMeshDriver driven (through MC) actors?

    upload_2020-5-9_13-8-50.png

    Is there anything special I should do if I have unity trigger colliders/rigidbody (beyond iskinematic/disable gravity) on same object? (for trigger collision detections).
    upload_2020-5-9_13-15-5.png
    upload_2020-5-9_13-15-18.png
     
  17. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Okay so a small update. I got the rotation to work (sort of) however due to the actor controller its doing a lot of work that really doesn't fit will with motions that need to be paired on both sides (Attacker / victim)

    Is there a way to get these animations to run without any interference by the actor controller?

    I have attempted to disable to actor controller but then I at the same time lose valuable movement (root motion) is there a way to avoid rotation?

    i have also tried to set the mRotation variable to identity but without any luck?

    hopefully someone here is able to help :)
     
  18. Tryz

    Tryz

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

    I did a quick test using my demo_NavMesh scene with just the one NPC and I'm seeing what I'd expect:


    Unlike your screen shot, I don't have a "Physics.SyncRigidBodyTransform" which is what I'd expect. It makes me think your characters have a different setup and that may have an effect.

    Could you email me (tim@ootii.com) your scene and I'll take a look over the next couple of days. I think that's the best way for me to help.

    P.S. Please include the whole project and your Unity Invoice ID. Thanks.
     
  19. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    On the AC, there's a property called "Use Transform". If you check that (or set it through code at strategic times in your game), the AC will stop moving and rotating your character, but it will allow other processes like the MC to continue to run.

    If the case of tight animation coupling (ie attacker & victim... like your image), that may be the best way for your AI to take 100% control of on-the-fly movement and rotation. The default of having "Use Transform" unchecked would use root-motion from your animations, but I have a feeling you're trying to line the character's up to the perfect position before you run the attack/defend animations. The previous post should have fixed like like I do in my interactions demo. However, if there's really fine tuning being done, maybe checking "Use Transform" temporarily will help.

    The other option is to totally disable the AC and MC. Then, they aren't in the loop at all. However, you shouldn't have to go that far.
     
  20. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363

    So this did work however it has a fallback.

    The camera doesn't follow the character which makes it look rather odd (check picture below) (I am using the 3rd person follow camera motor)

    upload_2020-5-10_13-1-2.png
     
  21. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    Thank you, I'll try to trim down the project and send it.
    I think the Physics.SyncRigidBodyTransform is just something unity exposed in 2019.3 but I maybe mistaken. I see it in default nav mesh demo too. I tried deleting all the colliders and rigidbodies from my characters but I still get this fps drop.
    The ActorController Late Update keeps increasing overtime until fps goes down to 0.
    Edit: this seems to be connected with grounding mechanics. hmm I'll investigate.
     
    Last edited: May 10, 2020
    Tryz likes this.
  22. Hurtful-Toad

    Hurtful-Toad

    Joined:
    Feb 18, 2016
    Posts:
    20
    When I play 1st person and look up and down, I like the arms/weapon to stay in same screen view as if they are attached to camera. All of my favorite 1st person games behave this way. I was able to achieve it with a custom camera motor anchored to active arms object. I send the arms a copied set of animator parameters and forward animation events to MC from the active arms object. Making good progress now, Thanks!
     
    Tryz likes this.
  23. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Did you totally disable the AC or check the Use Transform option? By checking Use Transform, the cameras should still work. If you disabled the AC... I could see the camera stop. It's linked to the AC. I totally didn't think about that. hmmmm.

    I still would think the coroutine approach would work.
     
  24. axel182

    axel182

    Joined:
    Jan 17, 2019
    Posts:
    7
    I would also like to know if the new input system is being planned for implementation.
     
  25. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    I'll look into it and see what would be involved. I can't make any promises as to when, but I will look into it.

    Sorry, I missed your question about this from last month.

    The old KeyCode methods on IInputSource aren't called in very many places in the ootii suite of products. If you're building your own implementation, I think you can safely just return false in all of those methods.

    As I mentioned above, I will look at adding official support for the new Input System. I'm working on a fairly significant update right now and I'm not sure if I'll be able to do that as part of it or if it will have to wait until after. I already have a few ideas as to how I might approach this.
     
  26. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    I'll just add that the included Character Wizard sets this up on your character by default (it adds a kinematic rigidbody). It adds a "Physics Objects" layer to which those objects should be assigned to, and excludes this layer from the Actor Controller's collision layers (so that the Unity physics system handles those collisions).
     
    ml785 likes this.
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The new input system is in beta still. It's planning on being released with Unity 2020. Once it is, I will create an Input Source for it.

    You could create one now using the Input Source approach that I use. I use "sources" for this exact reason. There are tons of different input solutions out there and now Unity will be adding another.

    Check out this post and video on Input Sources if you want to try to create one now.
     
  28. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    Does ootti work with Emerald AI or any other AI solution?
     
  29. Tryz

    Tryz

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

    I haven't used Emerald AI myself, but they have a tutorial for the MC as well as other controllers here.
    https://docs.google.com/document/d/...uHce2BVLM3QTq5axg/edit#heading=h.cnwwoen8fbuk

    You'll also find integrations with other AI systems like Node Canvas and Behavior Designer here:
    ootii Vault

    Most AI system will require some form of integration with character controllers, but they should work.
     
  30. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    What would be the earliest point it's safe to call MC action to activate after prefab was spawned?
    For example, I have animated copies of characters appearing in dialogue and I want to assign dialogue pose asap, so I can display them fast.
     
  31. Tryz

    Tryz

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

    Once Unity loads and initializes the animator
    and animations. Since most motions rely on Mecanim, you will need that ready to go.

    You will want to do some tests with the version of Unity you are using to know exactly when that is.
     
  32. Smellydave

    Smellydave

    Joined:
    Sep 20, 2013
    Posts:
    6
    Edit: Solved This - sorry - in DamagedReactor :) - I am Dumb!!


    Hiya,

    I am trying to add a shield system (as in a sci fi hits shield barrier before health rather then old style shield).
    I have set up the shield attribute in basic attributes but cant see in actor core (if it is in here) where I put in the hit shield before health code....I thought it would be in OnDamaged but seems not:)

    I am using MC, shooter and spells.

    thanks if anyone can point me in the right direction

    Dave
     
    Last edited: May 21, 2020
    Tryz likes this.
  33. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    So i have this issue that my character gets stuck and the navmesh just "leaves" the body of the character:



    After an extended test I think I found out where the issue is, however, I don't know how to solve this:

    When an NPC plays an animation and the navmesh agent is being told to move the navmesh agent leaves the body while the NPC plays the animation. Sometimes the Navmesh agent jumps back onto the character but other times it straight up leaves him and never returns.

    Has anyone ever tried this? And maybe know of a fix?

    note that I have tried adding the "root" motion reactor to this but without any luck.
     
  34. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I just happen to be working in the Behavior Designer integration and saw this post pop up at the same time I ran across this code.

    Code (CSharp):
    1. // Force the agent to stay with our actor.  This way, the path is
    2. // always relative to our current position.  Then we can use the AC
    3. // to move to a valid position.
    4. mNavMeshAgent.nextPosition = mMotionController._Transform.position;
    Not sure if it will help you but seems relevant.
     
  35. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    It happens when an animation clip other than a walk/run locomotion clip uses root motion to move the character. During the motion, the NavmeshAgent is not moving the character, so the agent stays in place while the character moves. Sometimes it snaps to the character's position once the motion deactivates (sometimes pushing one character under another), and sometimes it does not.

    I do have a fix for this on the next update (no ETA as of yet). The fix itself is what @KeithBrown mentioned: forcing the NMA position to that of the Motion Controller's transform. I do that in the UpdateRootMotion() method in each motion that uses root motion to displace the character. This includes BasicAttack, BasicDamaged, and BasicDeath which don't displace the character using the default Mixamo animations, but which may do so with other animations (such as those from Kubold's sets).

    However, I didn't stop there. I don't like the idea of making anyone who is using the AStar Pathfinding Project or another steering library have to write custom motions just because they use that instead of Unity NavMesh. So I've created an INavigationSource interface and a default UnityNavigationSource implementation. I haven't written van AStar implementation yet, but I studied its API documentation while writing the INavigationSource, so it should work.

    The updated motions all force the agent position via the INavigationSource, if one exists in the character.

    That part is already done and has been for a few weeks. I've been doing some restructuring, clean-up, and refactoring over the entire code base, so I need to finish that up before the update is ready to go. It will require deleting existing files and re-importing (as some files have been moved or deleted) and we don't want to require people to do that very often. The last time was almost two years ago, so I figure we can get away with it again. ;)

    A quick and easy fix for the time being would be to create a component that just syncs the NMA position in its Update() method. Not an efficient fix, but it's low effort and gets the job done until we get the next update finished.
     
    Tryz and KeithBrown like this.
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I was getting to support this weekend and was going to say that. I'm glad you found it.

    Check out this info on reactors. They're a good way for you to customize different aspects of your character.
    ootii - Reactors
     
  37. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    The NavigateTo action in the Behavior Designer needs alot of work. The only way I could get the tree to work correctly was to uncheck Use Nav Mesh Agent Position on each NavigateTo Node, uncheck Use Transform on the Actor Controller and move all of the waypoints to the ground and bypass the off mesh links. I also had to move other obstacles out of the way as they would cause the agent to hang if it came near and touched them. Once I did that I was able to get the tree to run and repeat.

    I will continue to play with it and see what I can find regarding the off mesh links and the use navmesh agent vs. using the motion controller to drive the AI.
     
  38. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    The best visual results are achieved by using the NMA only to calculate the path and then having the Motion Controller actually perform the movement to the next waypoint on the path calculated by the NMA.

    So you need Use NMA Position (on the task) disabled as well as Use Transform (on the AC) disabled for this to work. This isn't really intuitive though; better documentation and tooltips would probably help.

    If you leave Use Transform enabled, then the built-in movement tasks as well as the Movement Pack ones are usable. But I find the movement isn't as visually pleasing.

    This sounds like more of an issue with the NavMesh bake settings. Do you have the height map enabled in the bake settings?

    It's been a couple of years since I've used the BD tasks for MC, but they worked fine for me navigation through fairly tight spaces, jumping across platforms, and climbing up 0.5m through 2.5m blocks via off mesh links. These tasks are pretty much lifted directly from the NodeCanvas ones and I don't think the code has changed for either. The NC tasks still worked correctly as if about 3 months ago. I'll have a look at the BD tasks again when I have a chance.
     
  39. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    @TeagansDad, I guess I really did not explain the problem very well. The Behavior Designer integration does not work out of the box by just hitting play in the demo scene. The NavigateTo node does not work if the Use Nav Mesh Agent Position is checked and the node is restarted. This can be seen in the first video below where I start with a fresh installation of the integration. When Jones gets to the second waypoint, the Behavior Tree is at the end and restarts. Because the all previous conditions are false, the last branch is ran again, however, Jones is trying to go to a position that he is already at and the NavigateTo node cannot handle this correctly, so it gets locked up in an endless loop in the code trying to get to the position and it just returns running all of the time instead of complete. This is why the flow does not work. Some of the steps in the videos are pretty verbose. I am used to working with clients that need their hand held in my industry which is not gaming.



    In the second video, I uncheck the Use Transform on the Actor Controller and uncheck the Use Nav Mesh Agent Position on the NavigateTo node. It works much better but the bake settings need adjusted.



    There is something incorrect in the NavigateTo code that when the Use Nav Mesh Agent Position is checked, it can never reset because it does not know that it is already on the position it needs to be on. This is what I was trying to say in my previous post but did a bad job of explaining.

    I will try to look at it some more today now that I remember more of how the motion controller works.
     
  40. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    Ok, i give up. I tried for the last hour to keep the actor from being caught on the navmesh edges as seen in the second video above. Any idea what to change? I feel like this is an extremely basic Unity thing and I cannot seem to get it right. I have increased the radius of my agent and rebaked but still no luck.

    I found this video where someone else had the same issue with Node Canvas

     
    Last edited: May 24, 2020
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    What I'm doing is using Unity's Nav Mesh Agent to get the next point and moving to it. I'm not calculating a new path or anything.

    If you disable all my assets and simply let Unity's Nav Mesh Agent control the character does it get stuck?

    I haven't had it happen yet, but the issue could be specific to the shape of the navmesh. Please send tim@ootii.com a small project where this occurs. This way I have the same nav mesh shape and setup.

    Also, make sure you disable collisions on the AC. You don't need it if something is controlling the character's position.
     
  42. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I just sent you a small project brand new project that contains the motion controller, behavior designer, and the behavior designer integration. I used the demo_Live scene in the integration. I tried disabling collisions multiple times and it also did not work. They might be on in save file. In the NavigateTo nodes i unchecked use Nav Mesh Agent Position and instead used the motion controller and I also unchecked Use Transform on the actor controller. The two videos I posted above is pretty much what you will see.
     
    Tryz likes this.
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Ok. I'll look this coming weekend.
     
  44. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    @Tryz, @TeagansDad So I was finally able to get back to this and investigate a little bit more and I found the issue with the NavigateTo node and why it stopped working when reaching the play waypoint in the Behavior Design

    In actuality, the NavigateTo node was stuck in an endless loop. When OnStart() is called, it sets the mDestination Vector to Vector3.Zero and calls the ClearTarget() method, so mDestination is never reset. Then it immediately goes into the OnUpdate() method where it sets the lDestination. However, to find the distance to target, it uses the mDestination which has been reset to Vector3.Zero.

    So this line should be
    Code (CSharp):
    1.             Vector3 lToTarget = lDestination - mNavMeshAgent.transform.position;
    instead of

    Code (CSharp):
    1.             Vector3 lToTarget = mDestination - mNavMeshAgent.transform.position;
    When using the mDestination value, the distance from the navmesh agent is always greater than the stopping distance because mDestination has been reset to zero but the navmesh agent has already been stopped and is not moving anymore.

    The same issue is in the Node Canvas integration but it is masked there by the fact that the Modify Attribute for hunger runs every tick so the hunger attribute increases much faster than what it does in the behavior designer integration. The node canvas integration will abort its current task when hunger reaches 100. You can see this after the actor reaches the second platform and jumps down. On the way to the play waypoint, the hunger value reaches 100 and the actor switches destination to eat. This does not happen in the behavior designer integration thus the actor heads to the play waypoint. Once at the play waypoint, the branch will run again and this is where the endless loop starts as it is trying to go somewhere that it can never reach because of the mDestination vs lDestination mixup.

    Anyway, that is how I see it. There is still an issue with the actor getting stuck on corners when not using the navmesh agent position.
     
    Tryz likes this.
  45. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    The error is there with Node Canvas also, it is just harder to see due to the hunger parameter updating every tick.
     
  46. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    The update that I'm currently working on includes a new version of the NavMeshDriver which is based on an updated version of the logic used in the BD and NC "Navigate To" tasks. Better to have that logic in a component than have to maintain it in two different behaviour tree integrations. :cool: If you have something else that you can work on, I'd recommend waiting for the update. I don't have an ETA for it yet. I got a bit too ambitious with a couple of things that I wanted to include, so I need to scale those down or drop them entirely for the time being so I can just get this update finished.
     
  47. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    I made the changes to the code, just playing around trying to decide which AI to use or to bite the bullet and code my own. I just noticed that the integrations were not working properly and wanted to find out why.
     
    Tryz likes this.
  48. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey Cool guys :) Have anyone ever gotten Rootmotions ragdol to work with the ootii motion controller?
     
  49. Tryz

    Tryz

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

    I started from the beginning of the thread and I'm trying to work through it.

    What I found in the demo scene was that you have a couple of things changed from my scene:
    1. Unchecked "Use Transform" on the Actor Controller
    2. Added the Nav Mesh Input Source
    3. Unchecked the "Use Nav Mesh Agent Position" on each of the Navigate To nodes in the BD tree
    If I undid those changes, hitting play just worked. I also confirmed in a new project, new MC, new BD, and the integration from the vault, it worked just by hitting play.

    The way I did it allowed Unity's NavMeshAgent to control the position. So, we did exactly what Unity told us to and everything was as I expected.

    With your changes, you were having the MC control the position using root-motion through Behavior Designer's timing. That seemed to cause Unity's NavMeshAgent to not return the right waypoint data. Probably because I'm resetting the NavMeshAgent position in the Behavior Designer node. It could be that node's code is running at a different time then when I use something like my NavMeshInputSource.

    Putting your changes back, I did see the freeze at the corner...



    It looks like the MC is reaching the waypoint as the destination and the NavMeshAgent.steeringTarget is reporting that there's no new waypoint. This is odd, but it may be because we're trying to control the position in Behavior Designer's timing instead of letting Unity's NavMeshAgent do it.

    To fix this, I added a small amount to the target I'm telling the MC to go to. In NavigateTo.cs, I change line 396 from this:
    mMotionController.SetTargetPosition(mWaypoint, mWaypointNormalizedSpeed);

    to this:
    mMotionController.SetTargetPosition(mWaypoint + (mNavMeshAgent.desiredVelocity.normalized * 0.1f), mWaypointNormalizedSpeed);

    That stopped the pause at the waypoint because I'm telling the MC to push forward a little further. However, the NavigateTo node's logic will actually stop the NPC. That seemed to work well.
     
    Last edited: May 30, 2020
    hopeful likes this.
  50. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Hey, guys I really need some help :) I am trying to make a spear throw motion that is very very alike the archery motion however I cant seem to get it to work has anyone attempted this or know how to? My attempt of rewriting the archery failed its simply too massive :).

    Note if anyone is up for the challenge I will gladly pay its a huge part of my game :)