Search Unity

Motion Controller

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

  1. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Hi, I'm trying to get the motion controller to work with arbitrary rotations with the new Navmesh system. Part of why I got the Motion Controller in the first place was I loved how you had it already set up to orient to arbitrary rotations. I'm having some hiccups to say the least. I'm using your wall walking demo scene with navmesh surfaces built onto the wall and spherical surfaces. I'm using Behavior Designer with your custom 'Navigate To' action to drive movement (simply moving between two target cubes, one on the wall and the other on the cube. As you can see in the video there are some big hiccups with movement, stuttering while crossing the navmesh links, stepping off edges instead of following the navmesh, falling instead of staying oriented to the sphere, at times sometimes forcing orientation where it doesn't belong (such as jittering up to the the very top of the wall), and eventually getting flung way off altogether. And this video doesn't show it too dramatically but yes sometimes violently flung way off into the void and then falling....

    I've tried both the navmesh input and the navmesh driver... both have similar results...

    Of course if I'm using a basic navmeshagent on a capsule (i.e. no motion controller) I get pretty good results...

    Any ideas on how to maybe tackle this? I'm hoping to use animating AI and I'm using the basic idle and basic WalkRunStrafe motions as those are pretty similar to how I'll be moving most of my non-humanoid AI...

     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    When I created the NC and BD NavigateTo actions Unity hadn't released the rotatable nav meshes. So, I'm not really sure if the free stuff from my Vault even works with them.

    The Actor Controller and Motion Controller should be fine, but I have a feeling the NC and BD actions aren't giving them good info as the actions expect a constant up. To be honest, I'm not sure what the NavigateTo action is getting back from the new nav meshes.

    Once I'm done with the Shooter motion pack, I'll play around with the new nav mesh stuff. Until then, you may just need to create your own BD actions that support rotated nav meshes.

    [EDIT]
    Having your new NavigateTo action call the MotionController's SetTargetPosition() function should still be fine. As long as the AC is set to have the character orient to the ground, it should simply move to the position and tilt with the ground normal. The trick will be to have the target position be close enough to the character that it's not some arbitrary place in space.

    The other option is the MotionController's SetTargetVelocity() function. That allows you to set a direction. In this case, you'll want to have the direction move along the plane of the current nav mesh section.
     
    Last edited: Oct 7, 2017
    BackwoodsGaming and TeagansDad like this.
  3. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Hi Tim,

    I've been having a great time using NC with the ActorController on Use Transform mode for my AI. I've been having issues with these few things though:

    -I can't seem to get simulated input working. I spent a long time troubleshooting, but came up basically empty - does this not work due to the AC being set to Use Transform? Or is there something I'm missing?

    -Is there a good way to rotate an AI AC while stationary? Right now I'm using the RotateActorToTarget script you posted a while back, but it doesn't seem to animate the character.

    -What I'm trying to do with the above attempts is have the AI strafe or walk backwards, while keeping itself turned towards the target. I could've sworn there was a 'Focus' option added in a recent update, but I can't seem to find it, nor am I sure that it would even work in Use Transform mode. Is this feasible?

    I think I could use IK to make the actor seemingly strafe while moving laterally, but I don't think this would work with backwards movement.

    Thanks.
     
  4. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    The behaviour designer implementation has the "focus" option and it works great for that.... Not sure if or why the latest NC would be missing it, but I know for a fact the code is there in the BD implementation at the bottom of the Option vault.

     
    Tryz and tapawafo like this.
  5. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    You're right, it's there, but only when 'Use NavMeshAgent Position' isn't checked. I figure that's probably due to focus being exclusive to non-Use Transform functionality, so I'm not sure what to do still. I'll see if I can find turn on Focus just in case, but I'm not optimistic.
     
    Tryz likes this.
  6. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Exactly. That's what I was just typing. :)

    The reason is that when Use Transform and Use NavMeshAgent Position are checked, then the character is actually moved and rotated by the Nav Mesh Agent. I'm actually not doing any code. So, there's no way for me to force a rotation.

    If you don't check those options, then I do move and rotate the character and can do some fancier stuff. The downside is that you have to setup things like wander, patrol, etc. These are things the AI solutions typically have out of the box by controlling the transform (hence why I added the Use Transform option).

    In both cases, you probably want to use BasicWalkRunStrafe as that will give the sideways and backwards animations.
     
  7. tapawafo

    tapawafo

    Joined:
    Jul 25, 2016
    Posts:
    170
    Thanks for the quick response! :)

    I'm already using the BasicWalkRunStrafe locomotion - and from some short tests with higher rotation speeds on the RotateTowards script the results are surprisingly good for sideways movement - but is there something I can do to maybe stop rotation for a moment while using Use Transform? That way --

    Scratch that, it may be janky, but I simply turned the Rotation Speed up on the rotation script, and the AI can now move backwards perfectly! Awesome! :)
     
    Tryz and hopeful like this.
  8. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    A quick update on the Shooter Motion Pack...

     
  9. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Hello, I was wondering how I make the spells fire where I am looking vertically? It appears to be locked to a max and min vertical trajectory. Thank you for the great controller!
     

    Attached Files:

    • Untitled-1.jpg
      Untitled-1.jpg
      File size:
      131.4 KB
      Views:
      757
    • 2.jpg
      2.jpg
      File size:
      139.2 KB
      Views:
      744
    • 3.jpg
      3.jpg
      File size:
      119.4 KB
      Views:
      771
  10. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Magic Missile spell should be a good example:



    The IK will limit the character's bending to 45 degrees (just so he doesn't look goofy), but you can change that at line 209 of PMP_MotionBase.cs. By default, we'll launch from the direction of the hand or bone the spell node is tied to.

    Or, we can cast from the direction of the camera (which is typically limited to 85 degrees).

    In the Magic Missile, spell, I have the "Camera Direction" property checked to shoot the missile from the direction of the camera.



    From your pictures, it looks like you're using the Spawn Projectile node. Let me know if you're not.
     
    BackwoodsGaming likes this.
  11. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Thank you for your quick reply! I must be doing something wrong because default Magic Missile works the same for me, only horizontal. And yes I am use the Spawn projectile for my spell. upload_2017-10-10_6-37-48.png
    upload_2017-10-10_6-38-8.png
     
  12. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Are you sure that's the Spawn Projectile node you're getting to?

    Before that is a "Test Attribute Exists" node. If the character has an attribute called "NPC", it will take the left Spawn Projectile and not shoot from the camera.

    Go ahead and email an image of your attributes directly to tim@ootii.com.

    I'm also curious if my demo scene's Magic Missile spell casts as I show. That's always a good test.
     
  13. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Works in the demo like it should, I can cast up I'll just work from the Demo and see what I can do. Thank you for the great support!
     
    Last edited: Oct 10, 2017
    hopeful and Tryz like this.
  14. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Its working great now thank you! Can't wait until I can afford the rest of your packs!
     
    Tryz likes this.
  15. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Hello again, I was wondering if you had an example of a spell that I could use as a magic shield that would protect the player from spell damage as long as the button is held down (like holding right click for example)? I'm trying to create a magic shield that uses Krypto's shield effects.
     
  16. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I haven't done this, but we can probably walk through it...

    Can you describe more about the spell.

    Is the shield a sphere, a half-dome, a shield for your arm, etc? Is it blocking projectiles, only spell based projectiles, or even non-projectile damage like from my Emulation or Firewall spells? Does any damage get through or does it block 100%? Will the spell have any physics effects (for example, will a projectile collide with the sphere... what about Firewall flames)? Why the "as long as the button is held down"? Is this spell active 100% of the time like a regular shield? Does the spell expire?

    Planning out the details of the spell is always the first step. Then, you can start breaking it apart into smaller pieces.

    When you start going through the spell actions, there's some obvious ones that would help:
    Spawn GameObject (for the shield)
    Spawn Particles (for flashy particles)
    Test Attribute Exists (for resistances)
    Utility - Wait for Input (for key presses)

    Then, we many need to add some new actions. For example...

    My "Utility - Wait for Input" only looks for "Is Pressed". We'll need to modify it to support "Is Released" so we know when the button is no longer held.

    If the shield blocks projectiles 100%, you can probably just use a collider on your spawned GameObject. However, if you want the player to take some damage, then we'll probably need to change the "Damaged Reactor" on the Actor Core to one that can look to the attribute values and adjust damage before its applied.

    What you're asking is doable, but the details will determine how we do it and if any new code is needed.

    [EDIT]
    I don't mean for this long response to scare you off. :)

    I just don't have the vision for the spell as you do. So, the details will help me determine how it should come together.
     
    Last edited: Oct 12, 2017
    tchris and hopeful like this.
  17. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Well ultimately I would like to see an energy shield that can be used as long as right click is held but is dependent on a mana pool to work but I don't expect you to figure that out for me. I have it working with simple hard coded right click and it spawns a nice shield right on me that negates all damage and I am loving this so far.
    Code (CSharp):
    1. if (Input.GetButton("Fire2"))
    2.         {
    3.             string lName = SpellInventory._Spells[10].Name.Replace(" ", "\n");
    4.  
    5.             BasicSpellCasting lCastMotion = MotionController.GetMotion<BasicSpellCasting>();
    6.             if (!lCastMotion.IsActive && (!lCastMotion.RequiresStance || MotionController.ActorController.State.Stance == EnumControllerStance.SPELL_CASTING))
    7.             {
    8.                 MotionController.ActivateMotion(lCastMotion, 10);
    9.                 Debug.Log("You should be firing the spell : " + lName);
    10.             }
    11.         }
     
    recon0303 and Tryz like this.
  18. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hahaha... Well, that was easier than the road my brain went down. Good job! :D

    How are you stopping the spell with the Fire2 button being released?
     
  19. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    With the archery pack, is there a message sent that I could capture with a Reactor that says when the bow has been drawn and another for when it is released? I tried looking for PreAttack and PostAttack but that does not seem to work.
     
  20. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I don't have one for "drawn". When the BasicRangedAttack motion is active, an arrow will always be drawn (or in the process of being drawn).

    For releasing, I do send that to the Actor Core. It's ATTACKER_PRE_ATTACK (1100). I do that at line 1107 of BasicRangedAttack.cs.

    Right after the arrow is released, I then send ATTACKER_POST_ATTACK (1149). I do that at line 258 of BasicRangedAttack.cs.

    I confirmed they both worked by adding a Debug Log reactor for each and setting the Message ID and Text properties.

    When you said PreAttack and PostAttack didn't work, how did you test them?
     
  21. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    Okay when I said it did not work, I was thinking PreAttack might be when the bow is drawn but now that I think about that I see why that wouldn't be right.

    But I now see that there's an animation event for BeginDraw so I think I can use that .Thanks
     
    Last edited: Oct 13, 2017
    Tryz likes this.
  22. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    I just set it on a timer to last 5 seconds
     
    Tryz likes this.
  23. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    @Tryz

    I have the Camera controller asset and i was wondering if there is a way to stop the camera from moving with my input when i click on UI ? Can you help?
     
  24. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You'll want to disable the Input Source your camera uses when you click on UI.

    You can do something like this:
    Code (CSharp):
    1. CameraController lCC = gameObject.GetComponent<CameraController>();
    2. lCC.InputSouce.IsEnabled = false;
    There are some things that can help determine if you're over UI:
    https://docs.unity3d.com/ScriptReference/UI.Selectable.OnPointerEnter.html
    https://docs.unity3d.com/ScriptReference/UI.Selectable.OnPointerDown.html
    https://docs.unity3d.com/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html

    You'll have to check what works for your game scenario, but it should just be a matter of using the InputSource.IsEnabled property.
     
  25. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I was asked this morning how to limit the arrow count in the Archery Motion Pack. It's a great example of how you can use Reactors to customize your game play!

    Check out the answer and code here:
    How do I limit the arrow count for my bow?

    With this approach you have tons of control without modifying any of my code.
     
    Last edited: Oct 14, 2017
    hopeful, tchris and Salja like this.
  26. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    tim can i use the Basic Attributes on a creature without actor Controller or Motion Controller for the damage imput handeling ?
     
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Absolutely. :)

    In fact, I use it on things like the ground for tagging properties.
     
    Salja likes this.
  28. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    maybe you can explain to me how to do it best I have a creature I give this basicAttribute "100 Health"
    but what I must now call exactly when I get with the sword so the creator knows how much live they get deducted
    and the whole also different rum if the creature damage makes the Player

    maybe you can explain it more precisely I find it very interesting ootii synonymous for creaturen to use

    i will use node canves
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    I think your best bet is to just follow what I do with the Actor Core reactors.

    All my weapon systems will send a damage message to the Actor Core if it exists on the target or creature. The Actor Core then sends the message to the Basic Damaged Reactor (or what ever reactor you choose to handle the damage).

    In the Basic Damaged Reactor, I update the health attribute based on the damage that was set as part of the damage message.

    So, my flow requires the Actor Core to get the damage message from the attacker.

    If you don't want to use an Actor Core for some reason you would have to either modify the Weapon/Projectile Core to send the damage message as you'd like or tap into the attacker's Post Attack Message and then send the message.

    Check out the following code:
    WeaponCore.OnImpact()
    BasicDamageReactor.Activate()
     
    Salja likes this.
  30. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    Is there something special I have to do in my scene to get Spell Targeting to work? I'm trying to cast Firewall and Teleport and all of those targeting spells. In the demo I see the target on the ground to select the position but in my scene it does not show up.
     
  31. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    ah ha....I figured it out. I was missing the Attribute on my ground with a tag "Ground" and my layer was wrong.
     
    Tryz and hopeful like this.
  32. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Hello everyone,

    I need help with a little problem.

    My player is drifting by itself when the controls are untouched. I tried disabling every components and it only stops moving on when I disable the actor controller.

    :confused:
     
  33. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Drifting would only occur if the AC thinks you are on a slope or gravity and your character aren't aligned.

    Is it possible that your character's up vector or the ground's up vector is not really what you're thinking it is?

    What about gravity... is that set to something other than (0f, -9.8f, 0f)?
     
  34. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Well, the ground is a flat terrain with a road a flat road mesh on top with no rotation.

    Gravity is enabled but i haven't changed is default values and afaik the up vectors are were they are supposed to be but I will reconfirm all that tonight.

    Thank you for pointing out the possible culprits.

    Cheers!
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    No one else has reported the issue. So, I'm confident it's something in scene setup or an issue with the road's collision normal.

    If everything looks right, feel free to email tim@ootii.com a small project and I'll look.
     
  36. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    I'd like to try to use some animations I have for a 2 handed sword. If I wanted to have another set of animations (idle, walk, attack, etc) for a different 2 handed sword can you give me some direction on how to support that?

    I would guess I would set up a new weapon set. But then would I create a new motion? To be clear, I still want the sword and shield motions but I just wanted to support different motions when the player equips a 2 handed sword.
     
  37. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    You just need to add the animation states to BasicIdle, BasicWalkRunPivot, etc, but use a different Motion Form for that weapon when you equip it. ootii's Sword & Shield uses 100, Archery uses 200, etc.

    Setting up BasicMeleeAttack is a bit more complicated, as you'll need to set up your own set of attacks, blocked states, etc. You can place these in a sub-state machine in order to keep BasicMeleeAttack tidier.

    Which set of two-handed sword animations are you using?
     
  38. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    Thanks that is something like what i was expecting but I wasn't quite sure of the details. For my new sub state machine I figured I could pretty much copy/paste the code from the BasicMeleeAttack motion and just have new L0MotionPhase Ids. At least that's my plan so far.

    Kobold's longsword animations. I couldn't pass up this sale :)
    https://assetstore.unity.com/packages/3d/animations/longsword-animset-pro-92239
     
  39. TeagansDad

    TeagansDad

    Joined:
    Nov 17, 2012
    Posts:
    957
    Nice! I bought it pretty much the day it came out. ;)

    It just so happens that I'm building a motion pack for Longsword Animset Pro (and Sword Animset Pro, and Sword & Shield Animset Pro, and Two-Handed Sword Animset Pro, and Archer Animset Pro... they all share a common core). I can pass along an early version to you if you'd like. You will likely want to customize and tweak it further to your own liking, but I think it will be a good base to start with.
     
    hopeful and Tryz like this.
  40. tchris

    tchris

    Joined:
    Oct 10, 2012
    Posts:
    133
    yeah I love Kubold's animations. I have 2 of his other animation packs. That would be amazing. I'd appreciate that. How would you like to share it?
     
    Tryz likes this.
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hopeful and tchris like this.
  42. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    And you were absolutely right!

    Somehow, I had a very tiny rotation on the X axis of my player... no clue when it happened...

    I had checked everything... TWICE! Can't beleive I missed that, hahaha.

    Thank you!
     
    Tryz likes this.
  43. artplayer

    artplayer

    Joined:
    Apr 16, 2016
    Posts:
    18
    Hello!
    I added a crouch animation through Simple Motion but would like to rotate the character's body next to the camera when squatting. Any tips on how to do this?

    Thank you!
     
  44. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    This is one of those questions that sounds simple, but really depends on your project. Keep reading. :)

    With the crouch, is it meant to just be a "crouch where you are" and that's it... or will it get more advanced?

    The reason I ask is that as a motion becomes more complex, using the Simple Motion really won't work. For example, if your "crouch" becomes a moving crouch (ie sneak) then you really want the logic of the Basic Walk Run Sneak motion as it allows you to move.

    What camera solution are you using? That could effect how this is done.

    For example, my Camera Controller has the ability to rotate the character. So, using a motor with that option checked will do it automatically.

    If you're using another solution, the best answer may be a coroutine that moves and rotates the character to the position and rotation you specify. I'm actually doing this kind of work now and will include a support function in the next Motion Controller update.

    This is the function:
    Code (CSharp):
    1.  
    2.         /// <summary>
    3.         /// Coroutine to move the character to a specific spot. This option is a bit different than
    4.         /// SetTargetPosition() and SetTargetRotation() as it forces the movement and rotation in a coroutine. This
    5.         /// can sometimes be better for small adjustments. Typically, you'd use a coroutine to call this coroutine in
    6.         /// order for the original coroutine to wait for this one. See BasicCoverStrafe.cs.
    7.         /// </summary>
    8.         /// <param name="rPosition">Position destination.</param>
    9.         /// <param name="rRotation">Rotation destination.</param>
    10.         /// <param name="rTime">Time (in seconds) to reach the destinations.</param>
    11.         /// <param name="rSmooth">Determines if we use smoothing in and out.</param>
    12.         /// <param name="rMove">Determines if we move.</param>
    13.         /// <param name="rRotate">Determines if we rotate.</param>
    14.         /// <returns></returns>
    15.         public IEnumerator MoveAndRotateTo(Vector3 rPosition, Quaternion rRotation, float rTime = 0f, bool rSmooth = true, bool rMove = true, bool rRotate = true)
    16.         {
    17.             if (rTime == 0f)
    18.             {
    19.                 if (rMove) { _ActorController.SetPosition(rPosition); }
    20.                 if (rRotate) { _ActorController.SetRotation(rRotation); }
    21.             }
    22.             else
    23.             {
    24.                 float lPercent = 0f;
    25.                 float lStartTime = Time.time;
    26.  
    27.                 Vector3 lOldPosition = _ActorController._Transform.position;
    28.                 Vector3 lNewPosition = rPosition;
    29.  
    30.                 Quaternion lOldRotation = _ActorController._Transform.rotation;
    31.                 Quaternion lNewRotation = rRotation;
    32.  
    33.                 while (lPercent < 1f && (rMove || rRotate))
    34.                 {
    35.                     lPercent = Mathf.Clamp01((Time.time - lStartTime) / rTime);
    36.                     //if (rSmooth) { lPercent = NumberHelper.EaseInOutCubic(lPercent); }
    37.  
    38.                     if (rMove)
    39.                     {
    40.                         Vector3 lStepPosition = Vector3.Lerp(lOldPosition, lNewPosition, lPercent);
    41.                         _ActorController.SetPosition(lStepPosition);
    42.                     }
    43.  
    44.                     if (rRotate)
    45.                     {
    46.                         Quaternion lStepRotation = Quaternion.Lerp(lOldRotation, lNewRotation, lPercent);
    47.                         _ActorController.SetRotation(lStepRotation);
    48.                     }
    49.  
    50.                     yield return null;
    51.                 }
    52.             }
    53.         }
    So, you can use it if you want. You just need to call it as a standard Unity coroutine:

    Code (CSharp):
    1. StartCoroutine(MoveAndRotateTo(Vector3.zero, mEndRotation, 0.7f, false, false, true));
    If you look in my BasicInteractions.cs you'll see I have a coroutine function called MoveToTargetInternal that does something similar. It's a little more complicated, but it takes a position and rotation target and moves the character to it over time.

    Hopefully the "it depends" makes sense now. If you need more help, let me know.

    Feel free to email tim@ootii.com if you prefer.
     
    Last edited: Oct 17, 2017
    tchris and TeagansDad like this.
  45. paindonger

    paindonger

    Joined:
    Sep 21, 2017
    Posts:
    17
    Hey Tim, I am having a little problem with the camera not staying with my head in first person view while jumping. Not sure what I am doing wrong. I am hoping you may have a suggestion. I also am wondering how to speed up the strafing movement?
     

    Attached Files:

    Last edited: Oct 17, 2017
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You have the camera anchored to the character's root (feet). When she crouches down the root doesn't change so the camera view doesn't change. For a 1st person view, you'll have to figure out where you want the camera anchored to.

    Most AAA 1st person setups actually have a bone in the character that is for attaching the camera. This way you can have it go down and forward when the character animates (bends down, jumps, etc).

    You may not have that, but you could anchor the camera to something other than the character's root (feet) and then control the positioning as you need. For example, it could follow the character and change the height based on the head height after animations. You just have to ensure you don't add any crazy spine, neck, or head movement to the camera that makes the player feel sick.

    The strafing movement comes from the root-motion in the animation. So, you either speed up the animation in the Unity animator state or override the root-motion. In my Walk Run Strafe motion are some properties for Walk Speed and Run Speed. If they are > 0, I'll override the root-motion with the speed you set. Just watch out for foot slipping.
     
  47. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Hello Guys,

    I'm a little lost in all the AC, MC and Camera controler settings, I need a little help again :confused:.

    1- How can we prevent the left mouse button from enabling rotation of the camera when using a 3rd person fixed motor with Walk Run Pivot?

    2- How do we enable pivot on spot?

    3- Is it possible to use viewport relative controls for player movement but prevent the mouse from affecting the direction of the player while rotating the screen? I realise this is nuts but I want the player to be able to get a good look around what is comming for them from all sides without intefering with their controls or at least the ver least the direction they are currently running into. Not sure what I can do here.

    Thank you for your guidance,
    Fred.
     
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    The Unity Input Source includes a "View Activator" property. You can set that to "Middle Mouse Button". I'm guessing it's currently set to Left Mouse Button or "Left or Right..."


    I put the "View Activator" as part of the Input Source because so many things beyond just the camera need to know if the view is changing (ie targeting).

    There is a lot. If I were just creating assets for a specific game, we wouldn't need them all. However, that would mean the assets would be pretty limited too.

    In a couple of places, I describe the relationship between the assets. This is my latest attempt:
    ootii Character Framework

    I think of it like this:

    Actor Controller is the low-level character controller. It's responsible for actually moving the character, handling collisions, determining if we're grounded, physics, etc. Think of it like the engine in your car.

    Motion Controller is the high-level character controller that is responsible for complex motions (walking, climbing, jumping, etc). It manages the animations and tells the Actor Controller what to do. Think of it like the driver of your car.

    Camera Controller controls the camera. It changes the view.

    On each of these, you should be able to stay on the "basic views". With a couple of clicks, you can get standard functionality. Where things get hairy is when you want to do something beyond basic and want to customize something for your unique game (which you should be able to do). That's where the "advanced views" come in.

    When thinking about where a property would be, think about what you dealing with... the engine (raw movement), a motion (like walking), or the view.

    I hope that helps in some way.
     
  49. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hopefully the documentation and tool tips help. There's no doubt there's a lot, but you should be able to stick with the 'basic views' until you're more comfortable.

    Answered in my response to your previous post. ;)

    The "Walk Run Pivot" motion can be used. It has more advanced transitions (like pivot) than the "Basic Walk Run Pivot" motion does.



    I include different styles of movement (Walk Run Pivot vs. Basic Walk Run Pivot vs. Walk Run Strafe) because different people have different ideas of how their characters should move. By selecting the motion(s) you want you can have a movement style that fits your game play needs.

    I think I follow what you're saying. It sounds like the default "adventure style" movement that uses Walk Run Pivot.

    Open the demo_Terrain scene (Assets\ootii\_Demos\MotionController\Scenes) and press play.

    The player will rotate and move with "viewport relative controls". However, the WASD keys don't rotate the view.

    The view rotates only when the right mouse button is held. Notice that it does not affect the player while rotating the screen (unless you're moving).

    This is the default when you press "Adventure Style" on the basic view.

    If you go to the "Walk Run Pivot" motion and the advanced view and check "Use Tap to Pivot", your character will pivot when you tap the WASD keys.

    Is this close to what you're looking for?

    [EDIT]
    Another good place to start is the videos. They should walk you through all the basic setups. In the video below @4:53 I show the Walk Run Pivot motion.
     
    Last edited: Oct 17, 2017
  50. w409544041

    w409544041

    Joined:
    Aug 3, 2017
    Posts:
    52
    @Tryz

    My project will use shooter part,and i have bought sword,shield pack already.
    I am thinking about it will use my shooter part or shooter part created by you?
    If your shooter pack release time will two month later,i will create shoot part by myself.
    If your shooter pack release time in two weeks,i will wait for your shoot pack release.
    I am eager for your response.
    Thanks.