Search Unity

[RELEASED] Easy Character Movement 2

Discussion in 'Assets and Asset Store' started by Krull, May 5, 2021.

  1. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @duminju1990

    Thank you for your interest in ECM2!

    About your questions, honestly I have not tested it yet with multiplayer or playmaker, however in the end it is just a regular rigidbody acting as a character, so syncing it as a rigidbody plus some other fields should work for multiplayer. Having said that, in a future update I do plan to add native multiplayer support.

    It already include integration examples with Bolt so I think playmaker could be used instead of Bolt, in the end to move a Character, you just need to use its action commands, eg: SetMovementDirection, Jump, StopJumping, Crouch, StopCrouching, etc.

    And yes, I will keep adding new features and more mechanic examples along the road.

    Regards,
    Krull
     
  2. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello Artini,

    Than you for purchasing ECM2!

    About your question:

    Yes as @asored commented, you can use it for animal as long as you approximate your animal volume with the capsule an let it handle the locomotion, and use a more detailed collider hierarchy like hit boxes to say something (if needed). For example:



    Here the yellow capsule will be your Character's capsule and is the responsible to control all your movement, however in case you use additional colliders, make sure those do not collides with character's capsule collider.

    You can use the Character IgnoreCollision(Collider otherCollider, bool ignore = true) method to ignore additional colliders.

    However as commented HERE it has been developed for vertical oriented characters (e.g. Humanoids) where it can be rotated as needed, e.g. Like Mario galaxy, but the bottom part of the capsule will always represent the character's feet and the area designated to perform the ground detection.

    Regards,
    Krull
     
  3. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    About the LaunchCharacter function:
    Code (csharp):
    1. LaunchCharacter ( Vector3  launchVelocity, bool  overrideVerticalVelocity = false, bool overrideLateralVelocity = false)
    As you can see, you can use its additional parameter to override a velocity component or both, when false your given launchVelocity will be added to character's current velocity component wise otherwise it will override the character's velocity component wise too.

    About the InputActions, the only missing piece of your code, is enabling / disabling it, otherwise will remain innactive. e.g:

    Code (csharp):
    1.  
    2. // Initialize this class.
    3.  
    4. protected override void OnOnEnable()
    5. {
    6.    // Init Base Class
    7.    
    8.    base.OnOnEnable();
    9.    
    10.    // Enable our custom input actions
    11.    
    12.    interactInputAction?.Enable();
    13. }
    14.  
    15. // De-Initialize this class.
    16.  
    17. protected override void OnOnDisable()
    18. {
    19.    // De-Init Base Class
    20.    
    21.    base.OnOnDisable();
    22.    
    23.    // Disable our custom input actions
    24.    
    25.    interactInputAction?.Disable();
    26. }
    27.  
    If needed, you can find further information on the user manual "Adding a custom InputAction to MyCharacter" (page 35).

    Regards,
    Krull
     
  4. Artini

    Artini

    Joined:
    Jan 29, 2016
    Posts:
    181
    Thanks a lot for the tips.
     
  5. Artini

    Artini

    Joined:
    Jan 29, 2016
    Posts:
    181
    Ok, thanks. I need to look through all demo scenes, as well, to get a better understanding of ECM2.
     
    asored and Krull like this.
  6. Nashnir

    Nashnir

    Joined:
    Oct 30, 2015
    Posts:
    23
    I am hobbyist and extensively use ECM.
    One of my main issue was with performance when I would integrate stripped down versions of the controllers for Computer controlled characters especially in scenes with large amount of characters. It is also very much possible I am merely not technically proficient in it to implement an efficient derivative.

    My request is could please implement something like a stress test Scene with large crowds? (1 player controlled and rest with preset or random motion vectors)
    This way I have an idea and base to start off of.
     
  7. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Nashnir,

    Hi, thank you for your suggestion, I do plan to add some performance tests as part of future updates.

    As I just commented on asset page:

    By other hand, there are many ways to handle big crowds (all game specific) without the need to further optimize / strip ECM2, such a a "follow a leader" where other characters are just dummy placeholders, level of detail (on character movement method not graphically), etc. but as commented all game specific related.

    Having said that, remember to choose the right tool for the job, if your game requires a heavy amount of characters / objects (I mean thousands, like 100,000) you should take a look at DOTS, after all its being developed to solve those cases.

    Best Regards,
    Krull
     
    Last edited: Jun 7, 2021
    Nashnir likes this.
  8. Nashnir

    Nashnir

    Joined:
    Oct 30, 2015
    Posts:
    23
    Thank you and appreciate the detailed answer.
    I am planning to currently have around 15 ~ 30 max feature rich computer controlled NPC and 20~50 basic motion computer controlled NPC. Your reply answers my question. Thanks
     
  9. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Nashnir,

    No problem, glad I could help!

    Honestly, with that amount of characters I do no think you would need to further optimize it, if your game permits, you can turn off all physics interactions, while those are lightweight if no used is better turn those off, for example:

    upload_2021-6-8_16-33-29.png

    Another option, is keep you CharacterMovement stepOffset less than character's capsule radius, this will save some calculations needed for climbable steps (stepOffset is higher than character capsule radius).

    Regards,
    Krull
     
    Last edited: Jun 9, 2021
    JohnnyGo-Time likes this.
  10. NexonVision

    NexonVision

    Joined:
    Aug 30, 2018
    Posts:
    8
    Hey, I'm pretty new to the new input system. How could I make crouching a toggle instead of hold? Also how could I prevent sprinting while moving backward?
     
  11. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    About your question, in your custom controller (e.g. The one extending a Character class) simply override the OnCrouch InputAction Handler method and replace its implementation as follows:

    Code (csharp):
    1. // Overrides OnCrouch InputAction handler to perform toggle crouch
    2.  
    3. protected override void OnCrouch(InputAction.CallbackContext context)
    4. {
    5.     if (context.started)
    6.     {
    7.         if (!IsCrouching())
    8.             Crouch();
    9.         else
    10.             StopCrouching();
    11.     }
    12. }
    Now for the directional sprint, I assume you are using first person, the idea is first determine the character movement direction, and if moving backwards, ignore sprint multiplier.

    Here attach you a full example:

    Code (csharp):
    1.  
    2. using ECM2.Characters;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. namespace ECM2.Templates.FirstPersonTemplate
    7. {
    8.     public class MyCharacter : FirstPersonCharacter
    9.     {
    10.         // Overrides OnCrouch InputAction handler to perform toggle crouch
    11.  
    12.         protected override void OnCrouch(InputAction.CallbackContext context)
    13.         {
    14.             if (context.started)
    15.             {
    16.                 if (!IsCrouching())
    17.                     Crouch();
    18.                 else
    19.                     StopCrouching();
    20.             }
    21.         }
    22.  
    23.         // Determines if the character is moving backwards
    24.  
    25.         private bool IsMovingBackwards()
    26.         {
    27.             // Compute planar move direction
    28.  
    29.             Vector3 up = GetUpVector();
    30.             Vector3 planarMoveDirection = Vector3.ProjectOnPlane(GetMovementDirection(), up);
    31.  
    32.             // Compute movement direction relative to character's forward
    33.  
    34.             Vector3 characterForward = Vector3.ProjectOnPlane(GetForwardVector(), up);
    35.  
    36.             float dot = Vector3.Dot(planarMoveDirection.normalized, characterForward.normalized);
    37.             return dot < 0.0f;
    38.         }
    39.  
    40.         public override float GetMaxSpeed()
    41.         {
    42.             // If Walking backwards, ignore sprint modifier
    43.  
    44.             if (IsWalking() && IsMovingBackwards())
    45.             {
    46.                 float actualMaxSpeed = IsCrouching() ? maxWalkSpeedCrouched : maxWalkSpeed;
    47.  
    48.                 return actualMaxSpeed * GetSpeedMultiplier();
    49.             }
    50.  
    51.             // Call base method implementation
    52.  
    53.             return base.GetMaxSpeed();
    54.         }
    55.     }
    56. }
    57.  
    Last but not the least, I recommend this article to get familiar with unity's new input system, is really great and worth the read!

    Regards,
    Krull
     
  12. NexonVision

    NexonVision

    Joined:
    Aug 30, 2018
    Posts:
    8
    Thanks a bunch! Got anywhere I can donate to you? I really appreciate this effort you put into this :)
     
    Last edited: Jun 11, 2021
  13. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @NexonVision,

    No problem, glad I was able to help you :D

    Regards,
    Krull
     
  14. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Hi @Krull, I bought ECM2 and am in the process of migrating my character controller to it. The first impression is already very good! Very nicely structured and good documentation.
    I must say, all the examples enhance this asset so incredibly much!
    Others have already mentioned that a climbing system, or at least a ledge-grab system would be incredibly helpful - I can agree with that.
    I understand your arguments that ECM is a general purpose controller. But the examples you provided with ECM2 add so much value compared to ECM1.
    Thanks for your outstanding work! I'm looking forward to future updates :)
     
  15. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hey @baumxyz

    Thank you very much for such kind comments :D

    Yes, as per update, among fixes and new features, I plan to keep adding examples such as climbing, wall-grab, wall jump, ledge-grab, auto-jumps (like ocarina of time), wall-run, etc so you can rest assured this will only improve over time.

    Kind regards,
    Krull
     
    baumxyz likes this.
  16. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    Hi,

    Have been using ECM1 and now looking into using ECM2, I was quite interested in the bolt implementation examples as I like the visual state machine in bolt. I noticed that when I open the example in 2021.10 all the (Bolt) character are showing as missing scripts, they work fine in 2020.x where you have to import bolt. Probably something to do with the way the integration of bolt works in 2021.

    Just thought I'd let you know, thanks for a fantastic controller.
     
  17. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Broudy001,

    Yes, the Bolt examples included are Unity 2019.x.x and 2020.x.x compatibles as those based on the bolt package from store, having said that I am working on updating those to Unity 2021.x.x and will be included in the next update, however once released (following days) I will post them here so you don't have to wait to next update.

    Thank you :D

    Regards,
    Krull
     
    Broudy001 likes this.
  18. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Is there an estimated release time for that? Soooo awesome what you have done and are doing!
     
  19. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @ml785,

    While not a fixed date, I plan to release updates every 2-3 months unless there's a critical bug.

    Thank you!

    Best regards,
    Krull
     
    ml785 likes this.
  20. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    @Broudy001 @ml785

    As commented before, here I attached the updated Bolt examples for Unity 2021.1 Visual Scripting as included bolt examples are for the bolt asset store version.

    These examples will be included within ECM2 in the next v1.0.3 update.

    - Krull
     

    Attached Files:

    ml785 and Broudy001 like this.
  21. Limam

    Limam

    Joined:
    Jun 3, 2019
    Posts:
    1
    Hello Oscar,
    Thanks for your great work.
    is there any chance to put a " Photon example " , since i tried to modify the script a lot of times but there always something wrong there .
    best result was when disabling force affect characters , but still sometimes when player touching another , will got a huge velocity and went out on the space !
     
  22. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    @Krull

    Hi,

    Thanks for the bolt examples, I've had a look through them. I've found an issue, which I'm not sure if its me or not. I have a PlayerCharacter class which inherits from the Character class, I have this attached to my Character along with the Bolt State Machine, and the character movement script. The movement works fine, but when I try to call Crouch() or Sprint() or Jump() I get the error below;

    "MissingMethodException: PlayerCharacter.OnCrouch Due to: Attempted to access a missing member.
    System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <adfa4b62400849189388df71c9e26e89>:0)
    UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
    UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)"


    The only thing in the Player class is a method to calculate the movement direction from the input actions which works fine. I get the same problem for Sprint and for Jump. I think it has something to do with the event for OnCrouch etc, but I don't know how to resolve it.

    I've tried doing an embedded graph and a separate asset with the same error. I've tried overriding the Crouch and StopCrouching methods in my Player class, but the same thing happens.

    Any guidance or assistance would be greatly appreciated.
     
  23. EternalDeathSlayer3

    EternalDeathSlayer3

    Joined:
    May 7, 2015
    Posts:
    6
    Hey there, I'm just getting started with this asset and am trying to set up a character with root motion animations. The controller and the movement seem to be fine, but I'm getting a strange bug with the player animation itself. The character wobbles and jitters around while running. I'm using a basic running animation from Kubold's Movement Animset, and I've got the root motion option checked on the character controller and added the RootMotionController to the animator - is there another step that I'm missing, or any recommendations? My best guess is that the root motion rotation curves are either being ignored or misapplied. This is just the model with the animator
    rootMotion1.gif
    .... and this is the same with the ECM controller
    rootMotion2.gif
     
  24. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    I haven't tried the Kubold Movement set with ECM2 yet, but I'm using the Kevin Basic Motions Root Motions, and I've just done the same as you, and I'm not seeing that happen. Which rotation mode are you using?
     
  25. EternalDeathSlayer3

    EternalDeathSlayer3

    Joined:
    May 7, 2015
    Posts:
    6
    I have it on 'none' right now, but I tried each of them and got the same result. For the character rotation I'm just manually updating the transform
     
  26. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    577
    BUT, Have you tried rendering him at a different color?
     
  27. EternalDeathSlayer3

    EternalDeathSlayer3

    Joined:
    May 7, 2015
    Posts:
    6
    OMG that would be cheap AND quick! lol
     
    Pixelith likes this.
  28. asored

    asored

    Joined:
    Nov 6, 2020
    Posts:
    22
    I think this has nothing to do with the character controller. I had the same issue with my Root Motion animations. The solution was changing the following settings on the animation itself:



    I hope this helps :)

    Best regards.
     
    Krull and Broudy001 like this.
  29. EternalDeathSlayer3

    EternalDeathSlayer3

    Joined:
    May 7, 2015
    Posts:
    6
    Thanks for the reply, but the import settings match those perfectly. I don't think it's the animation itself, otherwise it would look wrong without the controller as well.
     
  30. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Limam,

    Thank you for purchasing ECM2 and happy to know you like it!

    About photon, yes I would like to add some integration examples, I am aiming for PUN and Photon Bolt, however being 100% honest, I need to do some research first as I am not really familiar with those solutions.

    Having said that, the character being launched off tells me the Character class is not being enabled or not updated, so the character being Rigidbody based is behaving like a frictionless regular Rigidbody (dynamic).

    Regards,
    Krull
     
    Last edited: Jun 16, 2021
  31. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Yes, I noticed a few issues with visual scripting and Input actions, its not very robust right now, as you can see here

    It work some times other times InputAction are not shown, I could get it working in the following and hacky way...

    Open the example scene, and PLAY it, while example is playing, click Edit Graph from your character Script Machine, this will allow you to assign the input actions as follows:

    upload_2021-6-16_16-43-24.png

    Also, please make sure you add the PlayerInput as this is the link between your input actions and Visual Scripting (Bolt).

    I think until a better Visual Scritping / InputAction integration I will modify the bolt 2021 examples to use old input system.

    Regards,
    Krull
     
    Broudy001 likes this.
  32. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @EternalDeathSlayer3

    Thank you for purchasing ECM2!

    About root motion:

    Actually the regular movement and root motion movement path internally is treated the same way, the only difference is with root motion the desired velocity is given by the animation (root motion controller) while with procedural movement is calculated from input and current movement mode speed.

    Please make sure you add the RootMotionController component to you animated model as this is the responsible of feeding the animation velocity to the Character.

    While using root motion based movement or not, the Character control is the same so no need to update the transform manually since it is already managed for you when using OrientToMovement rotation mode and this could be the cause of your displayed issue.

    Can you share your Character script or how are you modifying your transform? as I already commented this is not really needed.

    Regards,
    Krull
     
  33. EternalDeathSlayer3

    EternalDeathSlayer3

    Joined:
    May 7, 2015
    Posts:
    6
    Oh, I just meant that I rotate the controller's transform along the global Y axis to turn the character with the mouse. I'm using a fixed camera behind the player instead of an orbiting camera, and then using root motion for forward/strafing. I'm not sure if it matters, but I'm doing that in a LateUpdate and also adjusting the character's spine bone to allow them to look up/down with the mouse (but that's not affecting the animation - I turned off that part of the script and the jitter still happens). And yeah, I've definitely got the RootMotionController script attached to the animator game object.
    Honestly, the root motion isn't that important to me, but even when I disable it I'm still getting the strange bouncing in the run animation. I've been looking at it more closely, and it seems like the character's hips are supposed to be slightly moving and rotating but it isn't being applied, which throws off the rest of the bones in the hierarchy. I'm not that great with animation though, so who knows lol. BTW, I haven't played around with a lot of the special features yet, but so far the controller runs like a champ (no pun intended) - so much smoother than the basic ones I was using before :)
     
    Last edited: Jun 17, 2021
  34. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    I was doing more testing yesterday, and I think I'm going to mostly at least for now use the visual state graph to turn on and off bools, for things like targeting etc, and use the input actions as you normally do in the script.
     
  35. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @EternalDeathSlayer3

    It should not affect as long as your Character rotation mode is set to None, otherwise the Character will also be rotating your Character.

    One important consideration when using root motion, is to remember you are basically controlling the animation with your input method (controller, mouse, etc.) so its important to feed the correct information to your AnimatorController.

    Well actually ECM2 does not use Animation in any particular way as this not force you to setup your model or animation in any way, for example, you can have a working character with no visual representation or not animated at all like the Capsule character. For this kind of cases is I suggest you make sure you are feeding the correct data to the animator, e.g. is it in world space? in local space etc. as this is animation dependent.

    he-he, thank you, happy to hear you like it :)

    Regards,
    Krull
     
  36. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Thank you for the update, unfortunately if using Visual scripting (Bolt 2021), seems a wise decision, as current new input system integration still needs a bit of work to get it fully working.

    Cheers,
    Krull
     
  37. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Hi,
    I'm having a problem where I'm trying to use a Hookshot script with Third Person Character
    The Hookshot is supposed to create a spring joint with an end point of where your Raycast hits (and does LineRenderer to draw the line from Player to RaycastHit)
    I unlocked the Third Person Character's cursor for this purpose. But when I hit play, clicking on the map does not work to move the hookshot line.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GrapplingGun : MonoBehaviour
    6. {
    7.     private LineRenderer lr;
    8.     private Vector3 grapplePoint;
    9.     public LayerMask whatIsGrappleable;
    10.     public Transform gunTip, camera, player;
    11.     private float maxDistance; //how far away we can grapple to
    12.     private SpringJoint joint;
    13.  
    14.     void Awake()
    15.     {
    16.         lr = GetComponent<LineRenderer>();
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {  
    22.         if (Input.GetMouseButtonDown(0))
    23.         {
    24.             StartGrapple();
    25.         }
    26.         else if (Input.GetMouseButtonUp(0))
    27.         {
    28.             StopGrapple();
    29.         }
    30.     }
    31.  
    32.     void LateUpdate()
    33.     {
    34.         DrawRope();
    35.     }
    36.  
    37.     void StartGrapple()
    38.     {
    39.         RaycastHit hit;
    40.         if (Physics.Raycast(camera.position, camera.forward, out hit, maxDistance, whatIsGrappleable))
    41.         {
    42.             grapplePoint = hit.point;
    43.             joint = player.gameObject.AddComponent<SpringJoint>();
    44.             joint.autoConfigureConnectedAnchor = false;
    45.             joint.connectedAnchor = grapplePoint;
    46.             float distanceFromPoint = Vector3.Distance(player.position, grapplePoint);
    47.  
    48.             //The distance grapple will try to keep from grapple point.
    49.             joint.maxDistance = distanceFromPoint * 0.8f;
    50.             joint.minDistance = distanceFromPoint * 0.25f;
    51.  
    52.             joint.spring = 4.5f;
    53.             joint.damper = 7f;
    54.             joint.massScale = 4.5f;
    55.         }
    56.     }
    57.  
    58.     void DrawRope()
    59.     {
    60.         if (!joint) return;
    61.         lr.SetPosition(0, gunTip.position);
    62.         lr.SetPosition(1, grapplePoint);
    63.     }
    64.  
    65.     void StopGrapple()
    66.     {
    67.  
    68.     }
    69. }
    70.  
    Is the reason for this apparent? Thanks for any insight.

    Edit- Alternatively, do you happen to have a hookshot script for ECC2 I can just reference?
     
    Last edited: Jun 17, 2021
  38. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    85
    Hello, anyone has any idea on how to get strafe movement in third person character?
     
  39. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    There is an example for lock target, but you'd need to update your animator with the x and z directions to use the strafe animations
     
    Mythran and Krull like this.
  40. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    In the example, the ray is being casted from camera position towards its forward vector, this is exactly the center of screen from camera's view.

    For this to work, you'll need to convert the mouse click position to world space position pretty much like the AgentCharacter does to implement the click to move.

    For example:
    Code (csharp):
    1. Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    2.  
    3. if(Physics.Raycast(ray, out RaycastHit hitResult, 1000))
    4.    worldPosition = hitResult.point;
    Unfortunately no, sorry.

    Regards,
    Krull
     
    ml785 and Mythran like this.
  41. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi, for this to work you'll need to change the movement vector so it is relative to the character's current view direction so the lateral movement is along character's right vector and forward / backward movement along its forward vector, for example:

    Code (csharp):
    1. Vector2 movementInput = GetMovementInput();
    2.  
    3. Vector3 movementDirection = Vector3.zero;
    4.  
    5. movementDirection += GetRightVector() * movementInput.x;
    6. movementDirection += GetForwardVector * movementInput.y;
    7.  
    8. SetMovementDirection(movementDirection);
    By other hand you can set the character's rotation mode to Orient To Camera View Direction, this will allow a strafe movement, however as @Broudy001 commented, you'll need to feed your animator the correct values.

    Regards,
    Krull
     
    Mythran likes this.
  42. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    85
    Hey, thank you for the reply!
    I have tryied the above one, and it does not work.
    All i get is a strange behaviour from the character leaning all over.

    Any ideias on the corrrect values to feed the animator?
    Thank you.
     
  43. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    The way I currently have it set up is using Root Motion animations, and I put the GetDirection().z as the forward amount, and the GetDirection().x as the horizontal amount, and i have a 2d Freeform Directional Blend tree.

    I have basically taken the lock target input code to update the movedirection if I'm strafing
     
    Krull and Mythran like this.
  44. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    85
    Krull likes this.
  45. Blatticus

    Blatticus

    Joined:
    Apr 10, 2019
    Posts:
    19
    Hey @Krull, love your work with ECM2! I'd been working to orient a character along the ground normal so that they stand perpendicular to the surface-- think Sonic on a slope-- but am encountering a situation in which the character's rotation is "stuttering" when right between two faces; seems like the character is being rotated along one ground normal, but then catches the other face as the "ground hit," and rotates towards that, back-and-forth. I had some thoughts about how to handle this, but I was wondering if you had any solutions as well?

    I'll be looking more into CharacterMovement's CheckGround. One solution would be orienting the character to a midpoint between the two ground normals.

    Thanks in advance!
     
  46. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Blatticus,

    Thank you for purchasing ECM2 and happy to know you like it!

    About your question:

    Well the ground normals given byECM2 can be too noisy (change frame to frame) so it's better to use a separate cast for this.

    H E R E you can find an orient to ground component, as commented it samples a 3x3 area and uses the average normal to perform the character orientation.

    This component (with some other features) will be added to the package on the next update.

    Kind regards,
    Krull
     
    ml785 likes this.
  47. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119

    Hi,
    Thanks so much, that worked! The only other thing is, I think that the player has a Grounded state that makes it so that if you hookshot to something far and high in the air, it slides Player across the ground rather than Player going into the air. Since I'd like Player to go into the air- Is there some sort of line I can put in the script to toggle off Grounded when grappling begins? Or how would you recommend approaching the solution? Cheers! =]
     
  48. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    137
    @Krull Hello there, how to disable input? e.g block input movement when the player press WASD. When the input is enabled, the player can press WASD.

    Edit:
    Oh, I found it by using
    GetCharacterMovement().Pause
     
    Last edited: Jun 20, 2021
  49. Broudy001

    Broudy001

    Joined:
    Feb 12, 2020
    Posts:
    72
    There is a method to disable the stick to ground its used in the jumping code, just can't remember what it's called
     
    Last edited: Jun 20, 2021
    ml785 and Krull like this.
  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @restush96

    Yes, that will turn the character into a kinematic rigidbody, however a more direct way is to set its movement mode to None, and when you want to re-enable, simply set its movement mode to walking / falling as these modes are automatically managed based on character's grounding status.

    To disable character movement and physical interactions:

    Code (csharp):
    1. SetMovementMode(MovementMode.None);
    And later to re-enable it:
    Code (csharp):
    1. SetMovementMode(MovementMode.Walking);
    Regards,
    Krull
     
    ml785 and restush96 like this.