Search Unity

[RELEASED] Easy Character Movement

Discussion in 'Assets and Asset Store' started by Krull, Apr 21, 2016.

  1. Wraix

    Wraix

    Joined:
    Oct 2, 2012
    Posts:
    4
    Hi

    I am a new user of ECM and pretty happy with it so far. I have a small issue with my character jump that i cannot figure out if it’s an animation problem or something i need to set or change in ECM.

    I am using a controller which inherits from base character controller with root motion and root rotation motion enabled.

    When i jump the character and it is facing world z = 1 the jump happens ok, but if i turn in any direction and jump, the jump rotates the character towards world z = 1. Any pointers to what i am doing wrong or what is going on? Any help would be appreciated.

    Kind Regards
    Marc
     
  2. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Wraix,

    A few things to consider while using root motion.

    First when an ECM character uses root motion, the animation velocity and animation rotation is directly fed to the Character Move method and character rotation, unlike the 'normal' movement which accelerates / decelerates towards its given desired velocity.

    So in order to jump using root motion, your jump animation should give the correct velocity as this will be directly used to move the character.

    Secondly, by default an ECM character disables root motion when the character is un-grounded, to avoid the above issue, as the included example jump animations does not include root motion support. In order to use root motion during your jump, you'll need to modify the BaseCharacterController Move method, and replace its last line:

    Code (csharp):
    1. applyRootMotion = useRootMotion && movement.isGrounded;
    to

    Code (csharp):
    1. applyRootMotion = useRootMotion;
    Last but not the least, depending on your animations, you will need to transform the moveDirection vector before fed it to your animator, for example, with the included Ethan character, its animations expect it to be in local space, as you can see in the Animate method of the Ethan character controller.

    Hope this helps you, however if you need any further assistance, please let me know.

    Kind regards,
    Krull
     
  3. Wraix

    Wraix

    Joined:
    Oct 2, 2012
    Posts:
    4
    Hi Krull

    Thank you so much for the reply it helped me figure out what was wrong. Turns out that i have a similar setup to your Ethan example, so the root motion on the jump is not there and movement can be done in local space.

    My problem was that movement needed to be relative to the player follow camera.

    Code (CSharp):
    1. moveDirection = moveDirection.relativeTo(playerCamera);
    Thanks for the help!

    Kind Regards,
    Marc
     
  4. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Wraix,

    Thats great! I am glad I was able to help.

    Best regards,
    Krull
     
  5. TPEUnity

    TPEUnity

    Joined:
    Jan 17, 2018
    Posts:
    36
    Is it possible to add support to properly use Animator.MatchTarget(); function? While it works when i set target speed to be the magnitude of animator velocity and increasing max lateral speed to something high enough it occasionally overshoots quite a bit, especially when velocity is high.
     
  6. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @TPEUnity

    While not really familiar with the match target feature, I think your best option when using it, its let it take full control of your character pausing the ECM character, when a ECM character is paused, it will turn the ECM character into Kinematic and allows the MatchTarget move the character without being 'interfered' by the default ECM movement.

    You can handle it depending on your character's current state, for example if walking uses regular movement, then if your character is 'climbing' pause it and let MatchTarget move it.

    Regards,
    Krull
     
  7. sarahlikespie

    sarahlikespie

    Joined:
    Apr 26, 2020
    Posts:
    2
    Hi

    Great asset so far. As a new user I had a question. I am applying force to an ECM agent using navmesh but after applying force, the pathing and rotation of the agent seem disturbed and it has trouble rotating and following the correct navmesh path as it did before applying the force, as tf the offset from the force is not taken into account. This despite SyncAgent, I also testing adjust the moveDirection to match the force but this does not help also using ForceMode.impulse.

    Code (CSharp):
    1.  
    2. if (m_navMeshAgent.isOnNavMesh)
    3.                 {
    4.                     m_navMeshAgent.enabled = false;
    5.                 }
    6.  
    7.                 m_controller.movement.DisableGroundDetection();
    8.                 m_controller.movement.ApplyForce(randomDirection, ForceMode.Force);
    9.  
    10.                 if (m_navMeshAgent.isOnNavMesh)
    11.                 {
    12.                     m_navMeshAgent.enabled = true;
    13.                 }
    14.  
    15.                 m_controller.movement.EnableGroundDetection();
    16.  
    Root motion is not enabled. In Update I am calling

    Code (CSharp):
    1.  
    2. RotateTowards(moveDirection);
    3.  
    In order to match direction.

    EDIT. in fact using
    Code (CSharp):
    1.  
    2. m_controller.movement.DisableGrounding(2.0f);
    3.  
    Seems to h ave solved it. Was enabling ground mid force the issue?
     
    Last edited: Jan 21, 2021
  8. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hello @sarahlikespie

    I think your issue could be related of how ECM works, I mean, at great sight an ECM character basically it will accelerate / decelerate its current velocity (including external forces) towards the given desiredVelocity (Returned by CalcDesiredVelocity method), however, so your given impulse will be affected by Character's current settings (eg: friction, acceleration, deceleration, etc).

    Another point to take into consideration, is to apply the force (ForceMode.Force) inside FixedUpdate or Move method (called in a FixedUpdate) as this force, however if you are just applying an impulse (an instant change in velocity), you can safely do in Update method.

    Your current solution basically works, because when ground is disabled (in your case by 2 seconds), the character will be not affected by its 'ground' settings (eg: friction, acceleration, etc), so your force/ impulse will be applied without any modification.

    As you can see here, your solution is one of the ways I suggest to perform a dodge / dash movement, so it should not cause any troubles.

    Let me know if I can help you any further.

    Regards,
    Krull
     
  9. sarahlikespie

    sarahlikespie

    Joined:
    Apr 26, 2020
    Posts:
    2
    Hi Krull

    Thanks for your assistance.

    I have another question if I may. I am following up about your answer earlier about applying faux gravity with characters running around spheres like mario galaxy.

    I have succeeded in this so far, using the provided walkthrough to rotate the character normal up:

    Code (CSharp):
    1. Vector3 smoothedNormal = Vector3.Slerp(characterUp, surfaceNormal, 10.0f * Time.deltaTime);
    2.  
    3. movement.rotation = Quaternion.FromToRotation(characterUp, smoothedNormal) * movement.rotation;
    In addition I am updating the gravity vector to point towards planet centre in Update()

    Code (CSharp):
    1. movement.gravity = ((transform.position - planet.position).normalized) * gravity;
    This works well and initially I thought my work was done, however I am having exceptional difficulty making the character walk beyond the equator as the moveDirection vector seems unable to move the character vertically down (-Y) as a forward motion and the character will rotate back around and never enter the southern hemisphere.

    I am using a 3rd person camera type set up and so the character needs to move relative to camera so I also apply as suggested:

    Code (CSharp):
    1. // Here we use the included extension .relativeTo...
    2.                 if (m_camera != null)
    3.                     moveDirection = moveDirection.relativeTo(m_camera.transform);
    Initially movement (no root motion) was taken care of simply like this, as per walkthrough:

    Code (CSharp):
    1. moveDirection = (new Vector3
    2.                 {
    3.                     x = Input.GetAxisRaw("Horizontal"),
    4.                     y = 0.0f,
    5.                     z = Input.GetAxisRaw("Vertical"),
    6.                 });
    This will not work and i thought the issue was the directin vector is not taking into account the slopes at the equator. With the camera at this point behind the player and looking down (-y) I reasoned making the direction relative to the camera forward vector should solve it so I tried this instead:

    Code (CSharp):
    1.  var cameraForward = m_camera.transform.forward;
    2.                 var cameraForwardHorizontal = new Vector3(cameraForward.x, 0, cameraForward.z);
    3.                 moveDirection = m_verticalInput * cameraForwardHorizontal + m_horizontalInput * m_camera.transform.right;
    However the same behaviour, a movement vector that is no longer on a normal flat plane is not tolerated, even when not applying the camera relativeTo apporach. Do you have any suggestions?

    I feel it is related to the moveDirection needing to be a world space vector somehow?
     
  10. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    25
    Hi again! I'm having some issues with creating "Bounce Pads" When my character enters the bouncing trigger or collider and I press jump at the same time it cancels out the bounce pad force. Also because I use a double jump if I hold the jump button while hitting the bounce pad I get a jump immediately after leaving the bounce pad trigger. What I want to do is if I'm on a Bounce pad for that split second I cant jump or double jump because they either add extra force or cancel out the bounce pads force.
     
  11. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @sarahlikespie

    Yes I was able to reproduce this issue in the example scene, I will perform some tests (time permits) in order to better track the current issue, so please bear with me on this.

    By other hand, while the given moveDirection vector is in world space,and the example just shows it axis aligned, it can be any direction you like, for example an Agent will set it as its desired movement direction.

    Internally (CalcDesiredVelocity method) will use this give moveDirection vector to compute our desired velocity (basically just moveDirection * speed), then this desired velocity is feed to the CharacterMovement Move method to perform the desired movement.

    This Move method (CharacterMovement component) ECM will align this desired velocity vector along its current surface so the calculations are performed on the surface plane.

    In the meantime, let me know if I can help you.

    Regards,
    Krull
     
  12. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hello @Amo-deus

    This is caused because by default the BaseCharacterController Jump method, use the ApplyVerticalImpulse method to perform the jump, this method overrides the vertical velocity so it will cut your jump impulse.

    To solve this, we need tol replace the ApplyVerticalImpulse with the following function.

    Code (csharp):
    1. /// <summary>
    2. /// Determines the Character's velocity to perform the requested jump.
    3. /// </summary>
    4.  
    5. protected virtual Vector3 CalcJumpVelocity()
    6. {
    7.     Vector3 velocity = movement.velocity;
    8.  
    9.     Vector3 upVector = transform.up;
    10.     return Vector3.ProjectOnPlane(velocity, upVector) + upVector * Mathf.Max(Vector3.Dot(velocity, upVector), jumpImpulse);
    11. }
    In the CharacterMovement Jump Method, replace the ApplyVerticalImpulse (line 612) with the following code:

    Code (csharp):
    1.  
    2. // Apply jump impulse
    3.  
    4. //movement.ApplyVerticalImpulse(jumpImpulse);
    5.  
    6. movement.velocity = CalcJumpVelocity();
    7.  
    This should solve your current issue, however if have further questions, please let me know.

    Regards,
    Krull
     
  13. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    25
    Thanks! That solved the issue of cancelling out the jump. But if I hit the bounce pad while holding down the jump button, as soon as I leave the trigger my character immediately goes into a double jump instead of having to push the jump button again after leaving the bounce pad. I added a timer and a bool to disable my double jump temporarily for a split second, but as long as I'm holding the jump button it still just activates the double jump once the timer and bool turn off. What I need to do is just completely cancel the double jump if I'm holding the jump button down while hitting the bounce pad and then reset it so that I have to release the button and press it again, if that makes sense. I think its because as long as you hold the jump button down, its trying to perform the midair jump method as soon as the requirements are met because the function is based on getButton and not getButtonDown. It works if I change:

    jump = Input.GetButton("Jump");
    to: jump = Input.GetButtonDown("Jump");

    but then the variable jump height calculation is lost.
     
    Last edited: Jan 30, 2021
  14. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Amo-deus

    I think your current issue could be caused by the bouncer code, in there you should override the character's vertical velocity so the Character's jump adds on top of the velocity given by your bouncer.

    I tested the following, jump on bouncer while holding the jump button, the character is bounced and in order to perform the second (min air jump), I need to release and press the jump button again.

    Here is the Bouncer code:

    Code (csharp):
    1.  
    2. public class Bouncer : MonoBehaviour
    3. {
    4.     public float bounceImpulse = 20.0f;
    5.  
    6.     private void OnTriggerEnter(Collider other)
    7.     {
    8.         BaseCharacterController characterController = other.GetComponent<BaseCharacterController>();
    9.         if (characterController == null)
    10.             return;
    11.  
    12.         // Temporary pause grounding to allow the character leave the ground
    13.  
    14.         characterController.movement.DisableGrounding();
    15.  
    16.         // Apply a bounce impulse, preserving character's lateral velocity and overrides its vertical velocity with bounce impulse
    17.  
    18.         Vector3 characterVelocity = characterController.movement.velocity;
    19.  
    20.         Vector3 characterUp = transform.up;
    21.         Vector3 characterLateralVelocity = Vector3.ProjectOnPlane(characterVelocity, characterUp);
    22.  
    23.         characterController.movement.velocity = characterLateralVelocity + characterUp * bounceImpulse;
    24.     }
    25. }
    26.  
    Yes, this is expected, as the current jump property performs internal logics, so it requires to be polled, eg: Input.GetButton("Jump");

    Worth note, the character's wont reset its mid jump counter until it becomes grounded again.

    Regards,
    Krull
     
  15. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    25
    Thanks for the reply!
    Unfortunately this only seems like a partial solution to my problem, mostly I'm just bad at explaining the situation I think haha. The character definitely needs to be able to continue double jumping after hitting the Bouncer again though. It's the first jump that needed to be added and then the double jump. For example: jump on bounce pad (treat it like normal ground) but if player jumps then add that force to the bounce, then be able to regular double jump when in air after. BUT if I hit the bounce pad and don't jump at the same time still add the regular bounce force, then while in the air be able to regular double jump. If I'm making any sense. But luckily I've gotten the problem figured out now! Thank you for the help it's much appreciated.
     
    Krull likes this.
  16. larry2013z

    larry2013z

    Joined:
    Apr 14, 2020
    Posts:
    36
    Hi @Krull,

    I was wondering if you could give us an update how Version 2 is coming along? Do you have an ETA?
     
    Pixelith likes this.
  17. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @larry2013z,

    I have planned to release it this month, so hopefully 2-3 weeks before it to be available on the store :D

    Regards,
    Krull
     
    Pixelith and larry2013z like this.
  18. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Honestly that was a lot quicker than I thought! Do you have any feature lists available to read?
     
  19. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Shiro_Rin

    While not exactly a list of features, as I am still working on docs and release materials, you can expect ECM2 to include all the features of ECM and more.

    ECM2 adds a higher level layer while ECM is a more 'to the metal' version. As previously commented ECM2 is a completely new product, for example in ECM2 a ECM2_Character requires a CharacterMovement component and the new Character class, this replaces the previous BaseCharacterController class.

    In ECM2 the CharacterMovement component (as in ECM) is the responsible of perform the Character movement (eg: move from point A to point B), however this now implements a much more robust 'collide and slide' algorithm capable of 'look ahead' and resolve collision before it actually happened offering a lot of flexibility.

    In ECM2 while the CharacterMovement is the responsible of perform all the 'geometric' work it delegates the Character to decide how to move, so now a user have full control of the Character's velocity directly from the Character's class, for example, you can modify its default friction based movement (greatly improved to btw ;) ) simply overriding the Character's CalcVelocity method.

    In previous ECM, users had to extend the BaseCharacterController, in order to replace the input, rotations, etc, however in ECM2 this is not obligatory! as the Character class is a robust and fully capable class by itself and makes use of the new Input System, so you can simply take full control of a Character using an external class (eg: PlayerController) without the need to modify the ECM2 Character at all.

    This new Character class includes a lot of functionality and now as part of this high level layer, now includes 'Movement modes' as it suggests this basically tells the Character how it should move through the world, this movement modes includes: Walking (for grounded movement), Falling (air movement affected by gravity), Swimming (Swimming through a fluid volume, under the effects of gravity and buoyancy) Flying (flying, ignoring the effects of gravity), custom movement modes etc.

    So basically now you will extend the Character class only if you decide to add custom functionality on top of it, for example implement game specific mechanics, like dash, climb, slide, etc.

    Last but not the least, here I attach a couple of pics of the new CharacterMovement and Character components so you get a better look at its included features.

    Regards,
    Krull

    Captura de pantalla (38).png Captura de pantalla (49).png
     

    Attached Files:

  20. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    I'm looking for a character controller asset to purchase.
    According to the article here, it seems that the new version of the asset will be released this month, so would it be better to buy the current asset, learn how to use it, and buy a new one? Or should i expect documents and tutorials to match the release of the new asset?
     
  21. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @seoyeon222222

    Thank you for your interest in ECM!

    About your question, the new version as commented above is a different product and is not a direct upgrade from current to new version (ECM2), as while they share the same goals of an easy to use and easy to extend, differences exists, however I think if you are familiar with current ECM version, should have no troubles at all using ECM2, as IMO it is easier to use.

    Having said that, yes, ECM2 will include over 30 examples ranging, from input (new input system), animation related, root motion, platforms, gameplay (eg: dash, slide, wall grab, fly, swimm, bouncers, etc), cinemachine (first person, third person, path following, etc), Bolt visual scripting, etc.

    So existing users and new users should not have issues getting most of it ASAP.

    Regards,
    Oscar
     
    Amo-deus, seoyeon222222 and Pixelith like this.
  22. mookfasa

    mookfasa

    Joined:
    Dec 21, 2016
    Posts:
    46

    Sounds awesome, cannot wait to try! Will the ECM2 have ledge grabbing?
     
  23. MaximilianWinter42

    MaximilianWinter42

    Joined:
    Jan 29, 2021
    Posts:
    2
    Hello, I wanted to ask how I can adjust the movment direction, so that it point into the direction the camera is facing?
     
  24. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @MaximilianWinter42

    You can use the included extension .relativeTo (ECM.Common namespace) to transform your moveDirection vector, for example:

    Code (csharp):
    1.  
    2. // Transform the given moveDirection to be relative to the main camera's view direction.
    3. // Here we use the included extension .relativeTo...
    4.  
    5. var mainCamera = Camera.main;
    6. if (mainCamera != null)
    7.   moveDirection = moveDirection.relativeTo(mainCamera.transform);
    8.  
    For a working example, I suggest you take a look at the walk through guide example #3 Movement relative to camera.

    Regards,
    Krull
     
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @mookfasa

    Thank you for your interest in ECM2, unfortunately it will not include a ledge grabbing mechanic out of the box, as the goal (like ECM) is to offer a robust general purpose where users can build their game mechanics on top of it.

    Having said that, I have planned to release a few game specific mechanics add-ons for it.

    Regards,
    Oscar
     
    Pixelith likes this.
  26. MaximilianWinter42

    MaximilianWinter42

    Joined:
    Jan 29, 2021
    Posts:
    2
    Hi @Krull

    Thank you for the quick reply. I already use relativeTo to make the movedirection relative to my camera, but I also want to turn the character automaticly to face the direction the camera is viewing. I took the code from one of your example controllers and added a RotateTowards, but this is giving me a constant forward motion. I want the character to play the turn animation so I editet the move direction instead of movment rotation.

    Code (CSharp):
    1.             float singleStep = speed * Time.deltaTime;
    2.             moveDirection = moveDirection.relativeTo(playerCamera);
    3.             moveDirection = Vector3.RotateTowards(moveDirection, playerCamera.forward, singleStep, 1.0f);
     
    Last edited: Feb 19, 2021
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @MaximilianWinter42,

    An ECM character by default will rotate towards your given movement direction (moveDirection property), so in your case, you should remove your last line (moveDirection = Vector3.RotateTowards(moveDirection, playerCamera.forward, singleStep, 1.0f); as we already have transformed the movement direction.

    In the UpdateRotation method, the character will rotate towards its current moveDirection vector at your current BaseCharacterController angularSpeed rate.

    However if you would like to use root motion to drive your character's rotation, you should enable the useRootMotion and rootMotionRotation.

    I suggest you following the example character controller (in examples folder) to see a working example of a controlled character.

    Regards,
    Krull
     
  28. Iainduthie

    Iainduthie

    Joined:
    Oct 30, 2013
    Posts:
    5
    I posted about this earlier but forgot to post again.

    Found out how to do crouching as a toggle in a super easy way or its horrible and i am bad at programming haha

    In the HandleInput method bit

    crouch = Input.GetKeyDown(KeyCode.C) || Input.GetKeyDown(KeyCode.LeftControl) ? !crouch : crouch;

    Then it will be a toggle.
     
    Krull likes this.
  29. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Can i expect ECM2 to be released within February?
     
  30. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @seoyeon222222,

    Unfortunately no, having said that I have a release date set for next Monday 8 March.

    Regards,
    Krull
     
    seoyeon222222 likes this.
  31. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Sorry for spamming your thread, but ECM2? Cooooooooool :D Can't wait!
     
    Krull likes this.
  32. taoleaf

    taoleaf

    Joined:
    Jul 15, 2020
    Posts:
    15
    Hey @Krull ,

    I'm thinking of getting ECM and integrating it into an existing project with another asset that handles input, animation and movement. That asset uses Unity's built-in CharacterController class, but all calls to its Move() method are limited to a couple scripts. Reading through the ECM docs it sounds like there may be an equivalent Move() method I can call on ECM's CharacterController. I'm trying to determine if I'd be able to keep all my animation and input code, and make modifications to call ECM's Move() method instead of the built in charactercontroller's move(). What arguments does ECM's Move() method take?

    Thank you.
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @taoleaf

    Well while ECM includes a Move method and a similar methodology to unity CC, its not a direct replacement, as an ECM character being a Rigidbody based controlled is moved by velocity, at great sight it will accelerate / decelerate the Rigidbody velocity to match our given desired velocity.

    ECM includes 2 move methods, one for instant (no accelerations) velocity change and mostly used by root motion and a second one who use friction, acceleration etc. to move the character, this is the one used when not using root motion.

    This is the signature of each Move method:

    Code (csharp):
    1.  
    2. /// <summary>
    3. /// Performs character's movement. Causes an instant velocity change to the rigidbody, ignoring its mass.
    4. /// If useGravity == true will apply custom gravity.
    5. ///
    6. /// Must be called in FixedUpdate.
    7. ///
    8. /// </summary>
    9. /// <param name="desiredVelocity">Target velocity vector.</param>
    10. /// <param name="maxDesiredSpeed">Target desired speed.</param>
    11. /// <param name="onlyLateral">Should velocity along the y-axis be ignored?</param>
    12.  
    13. public void Move(Vector3 desiredVelocity, float maxDesiredSpeed, bool onlyLateral = true)
    14.  
    15.  
    16. /// <summary>
    17. /// Perform character's movement.
    18. /// If useGravity == true will apply custom gravity.
    19. ///
    20. /// Must be called in FixedUpdate.
    21. ///
    22. /// </summary>
    23. /// <param name="desiredVelocity">Target velocity vector.</param>
    24. /// <param name="maxDesiredSpeed">Target desired speed.</param>
    25. /// <param name="acceleration">The rate of change of velocity.</param>
    26. /// <param name="deceleration">The rate at which the character's slows down.</param>
    27. /// <param name="friction">Friction coefficient to be applied when moving.</param>
    28. /// <param name="brakingFriction">Friction coefficient to be applied when braking.</param>
    29. /// <param name="onlyLateral">Should velocity along the y-axis be ignored?</param>
    30.  
    31. public void Move(Vector3 desiredVelocity, float maxDesiredSpeed, float acceleration, float deceleration,
    32.   float friction, float brakingFriction, bool onlyLateral = true)
    33.  
    34.  
    You should be able to port your character's movement to ECM retaining your input code animations, etc, however as stated above is not a direct replacement and should require some time getting familiar with ECM in general.

    Regards,
    Krull
     
    taoleaf likes this.
  34. devorenge

    devorenge

    Joined:
    Jan 26, 2020
    Posts:
    6
    I'm trying to apply a physic material to a platform to make something like Ice that the player can slide on. It doesn't seem to be working, is this possible with this asset?
     
  35. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @devorenge ,

    While ECM is a Rigidbody, actually is a modified Rigidbody acting as a Character, and as a such it does not support regular physical materials, however it is possible simulate different friction surfaces, modifying the Character's properties (eg: accel, decel, friction etc), depending of your Character's state and / or surface.

    For example, in your case, you can add a Trigger to your platform then on Trigger Enter, you set your low friction values, then on Trigger Exits, restore your Character's current values.

    Regards,
    Krull
     
  36. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    197
    Hi was wondering if it is possible to create a controller for a 2.5D sidescroller game with your asset. I have this asset for a while now but did not notice it. Also anything on 2D?

    Example game

     
  37. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Gamingbir,

    Absolutely, it can be used for 2D / 2.5 games like one on your video, however please keep in mind ECM only support regular Rigidbody and regular 3D colliders (eg: box, spheres, mesh colliders, etc), and do not support real 2D (Rigidbody2D, tiles, etc).

    Regards,
    Krull
     
  38. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    197
    Looks like I can't use sprites for it. I have to use 3D models for them to be effective. Just a note when I use a model using the 2D example my model face gets back of the head when I flip my character.

    here what is happening.
    1) when using sprites: https://gyazo.com/0e6ac46a230124eafff583102cae8df4
    2) when using models. note how it shows her face when flipping: https://gyazo.com/aaffc89eab9d0e447c951f1c44a4faaf

    Anyways, a really good asset for fps and anything 3D. But it looks like I have to make my own controller for the things I want. Wanted to try it since I have it.
     
  39. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    @Gamingbir,

    You just cant disable the character's rotation and flip your sprites (frames), so the character (3D capsule) rotation remains unaltered.

    You can disable rotation, setting angular rotation to 0, or in your custom controller, modify its UpdateRotation method, to disable rotation, or perform a side to side lock rotation instead of an interpolated rotation.

    I see and understand your point, and yes, some times is better use the right tool for the job ;)

    Regards,
    Oscar
     
  40. Mythran

    Mythran

    Joined:
    Feb 26, 2013
    Posts:
    85
    Hello, i've been trying to change the character movement to strafe on q press, which enables target mode.

    Code (CSharp):
    1. // Transform moveDirection vector to be relative to CAMERA direction
    2.             if (playerCamera.GetComponent<CameraManager>().isCameraAvoiding == false && moveDirection != Vector3.zero && playerCamera.GetComponent<CameraManager>().lockOnFlag == false)
    3.             {
    4.                 moveDirection = moveDirection.relativeTo(playerCamera);
    5.             }
    6.             // Transform moveDirection vector to be relative TARGET direction
    7.             else if (playerCamera.GetComponent<CameraManager>().lockOnFlag)
    8.             {
    9.                 Vector3 direction = playerCamera.GetComponent<CameraManager>().currentLockOnTarget.transform.position - transform.position;
    10.                 direction.y = 0;
    11.                 direction.Normalize();
    12.                 //moveDirection = moveDirection.relativeTo(playerCamera.GetComponent<CameraManager>().currentLockOnTarget);
    13.                 Quaternion tr = Quaternion.LookRotation(direction);
    14.                 Quaternion targetRotation = Quaternion.Slerp(transform.rotation, tr, angularSpeed * Time.deltaTime);
    15.                 movement.rotation = targetRotation;
    16. }
    The strafe mode is fine, but the rotation around the target when "a" & "s" keys are pressed is irregular.
    Is there a strafe movement example anywhere?

    Thanks
     
  41. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    197
    how do I disable the turning in head? Can't I just flip the character like in 2D games? This what I have for now:
    https://gyazo.com/facbd71b2d990831e9f75e52b41a2405

    how to add more actions to your controller? Example combos and etc.
     
  42. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @Mythran

    The idea when locking a target is move (eg: moveDirection vector) relative to us, and rotate towards our target (eg: look at), for example:

    Code (csharp):
    1.  
    2. protected override void HandleInput() {
    3.   // Handle user input (world space)
    4.  
    5.   moveDirection = new Vector3 {
    6.     x = Input.GetAxisRaw("Horizontal"),
    7.       y = 0.0 f,
    8.       z = Input.GetAxisRaw("Vertical")
    9.   };
    10.  
    11.   jump = Input.GetButton("Jump");
    12.  
    13.   crouch = Input.GetKey(KeyCode.C);
    14.  
    15.   if (targetTransform == null) {
    16.     // No target, move relative to camera's view direction
    17.  
    18.     moveDirection = moveDirection.relativeTo(Camera.main.transform);
    19.   } else {
    20.     // Have a target, move relative to us since we are looking at the target
    21.  
    22.     moveDirection = moveDirection.relativeTo(transform);
    23.   }
    24. }
    25.  
    26. protected override void UpdateRotation() {
    27.   if (targetTransform == null) {
    28.     // If we have no target, rotate towards movement direction (moveDirection vector)
    29.  
    30.     RotateTowardsMoveDirection();
    31.   } else {
    32.     // If we have a target, we look at target
    33.  
    34.     Vector3 toTarget = targetTransform.position - transform.position;
    35.  
    36.     RotateTowards(toTarget);
    37.   }
    38. }
    39.  
    In the above pseudo-code basically if we have a target, we look at and move relative to our current view direction (looking at the target), then if no target locked, rotate towards movement direction and our move direction is relative to camera's view direction.

    Regards,
    Krull
     
    Mythran likes this.
  43. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Yes you can simply lock rotation side to side instead of slowly rotate side to side, please take look at the included 2D example (Examples folder) for a working implementation.

    Basically we modify the UpdateRotation method (in your custom controller) as follows:

    Code (csharp):
    1.  
    2. protected override void UpdateRotation()
    3. {
    4.     // Rotate towards movement direction (input), in this case left / right.
    5.  
    6.     // Here we update character rotation to change direction instead of smoothly rotate to new direction
    7.  
    8.     if (moveDirection.sqrMagnitude > 0.0001f)
    9.         movement.rotation = Quaternion.LookRotation(moveDirection);
    10. }
    11.  
    You follow the same procedure outlined as above, you create a custom controller extending one of the included 'Base' controllers, and use this custom controller to add your game mechanics on top of the ECM default functionality

    I suggest you follow the Walk-through guide (at least examples 1-3 and 10) to get familiar with extending ECM.

    Regards,
    Krull
     
  44. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    187
    Is there any good news for ECM2?
     
  45. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Well unfortunately due to some unexpected issues (not ECM related) I could not accomplish my estimated release date of this last Monday, also I took the decision to not answer questions about its availability or estimated release date, so I appreciate your understanding about this.

    Having said that, ECM2 is nearly complete and you can rest assured I am working hard on its release, so hopefully it wont take much more longer.

    Once again, I appreciate your support and understanding in this regard.

    Regards,
    Krull
     
  46. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Hey @Krull, do you think it's possible to recreate the movement of CS:GO surfmaps? I want to be able to slide on slopes, but not necessarily fall down (depending on the momentum). With enough speed I would like to be able to navigate on the slopes.

    I use the FirstPersonController and have activated "slide on slopes" from 45 degrees. I have also deactivated "snap to ground" and increased the air movement to 1.0. Everything feels great so far, but surfing doesn't work yet. Reducing the sliding gravity multiplier to below 1.0 does not work since it's the minimum value.
     
  47. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @baumxyz

    I think part of your current issue is because by default ECM will bypass user input when character is sliding because of an invalid ground, to force the character to leave the ground.

    To modify this, you'll need to perform some minor changes to CharacterMovement to treat the slide off steep surface as a falling.

    Here you can find the steps needed to perform such modification, however if need further help, please let me know.

    Regards,
    Krull
     
    baumxyz likes this.
  48. MOhi

    MOhi

    Joined:
    Jan 29, 2014
    Posts:
    21
    Hi @Krull
    thanks for the great asset it's really nice and easy to use
    I have a little question, I tried to search if it were asked before but anyway simply I just need to force the character position to a certain position but it ends up above ground, even if I am sure that the position I added is correct
    I just set the transform of the object and also I am using the CustomAgentController with it's default setting

     
  49. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    772
    Hi @MOhi,

    Thank you, happy to know you like it :)

    About your issue, mmm, from the picture I cant correctly tell, but one possible cause could be a misplaced capsule center and or related to snap to ground feature.

    Please make sure your character's capsule center is correctly placed, for example, a default character of 2 units height, its center must be 0, 1, 0.

    By other hand, please make sure your Character's snap to ground (GroundDetection component), is enabled.

    Regards,
    Krull
     
    MOhi likes this.
  50. unity_qYF9IhUfSdNuiw

    unity_qYF9IhUfSdNuiw

    Joined:
    Feb 20, 2018
    Posts:
    2
    Hi, I really love your character controller. I have a question, at the moment I use your custom agent controller from the examples. How would it be possible to not move the character, but roating it torward the clicked position, when I left click? So It would move and turn on right click and only turn on left click. Thank you in advance.