Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Easy Character Movement

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

  1. Filhanteraren

    Filhanteraren

    Joined:
    May 14, 2014
    Posts:
    47
    Hi I have a small suggestion about jumping. I would like to be able to easily modify the jumping behavior for different kinds of jumping. Right now, if I understand it correctly you jump by getting a vertical impulse, but I would like for example make a jump that pushes the character more in the forward direction, like a long jump ( and not adding more height to it if that makes sense) Its possible with some custom code but I think it would be great if that was more easily accessible

    Edit: Also adding support for air or ground dashes would be cool but maybe that is a little bit to specific stuff for a general controller. :)
     
    Last edited: May 10, 2019
  2. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @Filhanteraren,

    Thank you for your suggestion, definitely will add it to the upcoming version, and yes, in the current version (1.6), the jump impulsed if fixed as a vertical only, however as you comment this can be easily modified, but should be easier for users if I add a general purpose (arbitrary direction) jump.

    For example you can add the following function to CharacterMovement component to compute a 'general' impulse:

    Code (csharp):
    1.  
    2.         /// <summary>
    3.         /// Apply an impulse to character. This will cause an instant change in character's velocity.
    4.         /// </summary>
    5.         /// <param name="impulse">The the impulse to be applied.</param>
    6.  
    7.         public void ApplyImpulse(Vector3 impulse)
    8.         {
    9.             _rigidbody.velocity = _rigidbody.velocity.onlyXZ() + impulse;
    10.         }
    11.  
    Having said that, a jump in general is basically a 'projectile motion' and I could add a helper function to jump towards a given point (eg: 2 meters in front of player position) but this behavior (its parabolic motion) will depend of the player settings (eg: gravity, friction, etc).

    HERE you can read a more in-depth explanation of this.

    About the dash, I suggest you implement it modifying the character's speed for a predefined amount of time (eg: dashTime), similar to the walk / run speed modified based on character's current state, this will give you the more control over the dash, alternatively you can create a dash animation and let the root motion handle the dash for you, however this method requires a special (non-in place) animation to work with root motion.

    Please do not hesitate to message me back if have any question or need any further help.

    Best Regards,
    Krull
     
  3. Fabbs

    Fabbs

    Joined:
    Dec 2, 2013
    Posts:
    42
    Sweet il check it out! Now with the reflection probe problem out of the way it's completely smooth and nice!
     
  4. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @Fabbs

    Excellent!, thank you for the update about the jitter issue, glad to hear its solved now.

    Let me know if need any further help.

    Kind Regards,
    Krull
     
  5. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    653
    Hi. Excited that I've finally bought the asset!
    Is there an integration with Aron Granberg's A* Pathfinding Project yet? (quick search of this thread suggests no but I've not read every post [yet ;-) ].
    Thx

    [Edit]
    P.s. any pointers on best way to approach this gladly appreciated

    [Edit 2]
    See this post for next update in this sub-thread.
     
    Last edited: May 16, 2019
  6. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    37
    Hey @Krull,

    I've been attempting to make my own rigidbody character controller work with moving platforms recently, I currently don't set velocity directly and always use addforce, so far I can't get the character to match the velocity of the kinematic platforms quickly enough (a shame as everything else it working as planned). So I started poking around with your controller again to see how you managed it so well, sadly for me your method sets velocity directly, which doesn't seem to play well with the rest of my own approach.

    I'm now trying to decide whether to keep banging my head against my own method or try to convert over to your system.

    I would appreciate your input on this. It's a character that is constantly hovering between 15 and 30cm from the ground (in it's current form this is considered "grounded"), moves forwards and backwards in it's local Z axis, turns by rotating on the Y axis (X+Z rotation are locked) and is able to thrust vertically based on a recharging amount of fuel. Can ride moving kinematic platforms, can also be pushed by other rigidbodies and forces.

    Would I be able to make ECM do all of this fairly easily?
     
  7. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    653
    Hey @Squeyed -- I suspect many who end up using this asset share your story of frustration writing their own ;-) Yes I used AddForce() too!

    Would you mind an ignorant question: must your character really not touch the floor? (I.e. could the visuals be off the floor but the capsule collider be offset?)

     
  8. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    37
    Hey @Arkade it's far from ignorant, I've thought about this every now and then myself, I don't think I can get away with that unfortunately, not easily anyway, there are situations where non-solid hazards pass below the character (between the ground and character) and other situations where the character enters spaces with lower ceilings, so there are obstructions to that technique above and below in a lot of scenarios. At the moment when the character is in a tight space I cast a ray upwards and the distance result decreases the hover margin to compensate, this would get complicated with a larger capsule collider.
     
  9. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    653
    heh, OK cool (though I will check the obvious that you've considered all sorts of hare-brained schemes involving layers and/or dangerously liberal use of IgnoreCollision() ?)

     
  10. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    37
    Yeah I've been on and off this task over the last year, I can't personally see how I can go that route without introducing a heap of new problems.

    I suspect the best course of action would be to make ECM work for me, however considering I'm already all set with a controller of my own, just finding a solution to make the character match platform velocity as well as rigidbody.velocity does (though with addforce) might be the least time consuming (he says after 2 weeks of trying).
     
  11. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    653
    sigh, yeah I know that feeling well. I've struggled with determinism of Rigidbody.AddForce() velocity. I naively (Newtononly?) thought I'd be reasonably simple but alas no (must be relativistic ;-) ).

    Seriously though it seemed like due to the ordering we can access. I assume you've been all over the various obvious approaches? (e.g. sticking a component [temporarily] on moving platforms and to get velocity then using difference between character velocity and platform's as a call to AddForce() with velocity change flag.) I suspect you'll end up with it wobbling and drifting a bit and you might be best off 'explaining' variance from 'proper' (expected) answer by tweaking the fiction of your game. As long as it stays roughly atop and doesn't fall off eh? (depending on your game's mechanics, etc.) I guess you could implement a PID controller or somesuch to compensate?

    Btw I'm saying all this in the hope that these dumb workarounds will be laughed at by a reader [from the future] who responds with avuncular admonition and a correct solution which I can humbly use for my remaining years :)

    i.e. I'd be very interested in suggestions or references on all this to improve my understanding :)

    p.s. sorry to OP if my dumb suggestions are a bit off topic! Hopefully it all contributes to the richness of use of your lovely asset :D
     
  12. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    37
    At the moment I do something similar, I compare the tag of the game object the downward spherecast hits, if it's "moving platform" I get it's velocity, break it down into direction and speed, then apply those with addforce to the character, I've gone through each of the forcemodes many times, "velocity change" was something I'd hoped would pretty much get the same result as directly setting velocity, alas, it didn't pan out that way for me.

    At the moment I get it moving at the right speed, just a quarter of a second too late, some of the platforms are very small so this can be an issue. I may settle for the current setup I have, but make platforms larger etc.

    I will wait to see what @Krull has to say first.
     
  13. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    653
    Update:

    Well, I've got a A* basically working. Reasonably straightforward but have to create subclasses of the A* movement classes since they don't seem to allow setting the `simulatedPosition` otherwise (only a 1 line class each so meh). Started with my primary need -- `AIPath`. Will move on to root motion etc later.
     
  14. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @Arkade,

    First of all thank you for purchase ECM! greatly appreciate it!

    About your question, unfortunately no, by default ECM does not include A* integration, however it includes a fully working BaseAgentController which uses the Unity NavMesh / NavMeshAgent, it is pretty straight forward to use, and should help as a example to create a custom controller to add support for additional AI solutions like Aron Granberg's A* Pathfinding Project.

    Having said that, the method I suggest while working / extending ECM, is create a custom controller extending one of the included 'base' controllers (eg: BaseCharacterController, BaseAgentController, BaseFirstPersonController), and override its required methods to modify its default behavior or add custom code on top of ECM default functionality.

    In your case, just like I do with the BaseAgentController, I suggest you create custom controller extending BaseCharacterController, and use this custom controller to add your A* related code, worth note that in the end, to move an ECM Character, all you need to feed its its moveDirection property, by user input, AI, etc. ECM will use this moveDirection property (direction vector) vector along with the character's speed property value to compute the final character's desired velocity.

    At great sight, ECM moves a character (Rigidbody) modifying its velocity, the character controller reads the user input (or AI set this) and use this input movement direction (moveDirection property) to calculate the character's desired velocity (CalcDesiredVelocity method), then the controller feeds this computed desiredVelocity vector to the CharacterMovement component (aka: character motor) Move method, which finally updates the Rigidbody velocity to move the character.

    The CharacterMovement component allow 2 different Move methods, one which will directly feed the given desiredVelocity to the rigidbody (cause an instant change in Rigidbody velocity) and it is used with RootMotion, where we supply the animator velocity (animVelocity property). The second method will accelerate / decelerate the Rigidbody velocity towards the given desiredVelocity vector, using the character's parameter (acceleration, deceleration, frictions, etc).

    Having said that, If need any further help feel free to message me to support email, I can take a look at your custom controller in order to better help you.

    Kind regards,
    Krull
     
    larry2013z and Arkade like this.
  15. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @Squeyed
    Yes, ECM is a 2nd order character controller (modify its velocity), where yours is 3rd order where you add forces and its a little more tricky to get it right.

    In ECM where I directly modify the Rigidbody's velocity as you can read in the above post, ECM at very great sight basically accelerate / decelerate the character's current velocity towards the character's desiredVelocity, using the character's properties (eg: speed, acceleration, deceleration, Ground Friction, etc), and set this modified velocity back to Rigidbdy.

    Here and with respect to platforms, ECM will treat this as 2 separate velocities, I mean, when a platform is detected by the GroundDetection code, I update the isOnPlatform property, and retrieve the platform (eg: kinematic Rigidbody) platformVelocity and the platformAngularVelocity, this is important because internally ECM use the chracter's velocity WITHOUT the platforms velocity to compute the final movement velocity (as you can see in the CharacterMovement velocity property), so the accelerations / deceleration, frictions, etc, will not interfere with the Rigidbody's velocity. Here worth note the Rigidbody's velocity is the character's velocity + platformVelocity (this is zero if not on platform).

    As a final step, and a important one, once the physics engine has computed (integrated) the new velocity and position for the rigidbody, I developed a SnapToPlatform function, here will 'rectify' the rigidbody's velocity with the integrated platform's velocity and most important FIX the character's position and rotation to the platform (eg: MovePosition, MoveRotation). This is done in a co-routine simulating a LateFixedUpdate.

    Maybe this kind of correction can help with your current controller, as this make a huge difference.

    Mmm, do you mean floating like a hover? I think this could be doable, and I actually have done it before, but hovering over ground (again applying a hover force based on ground distance) result in a floating behavior not a fixed distance.

    Another solution, ECM character can pretty much walk over 'obstacles' (eg: rocks in example scene) and high angled walls if desired, additionally as @Arkade commented, you can put those 'obstacles' in a different layer (non character collidable), or mark them as triggers, and those will not collide with the character capsule, but can use OnTriggetXXX functions to detect them if needed.

    About the ceiling, you can scale the capsule, worth note the current ECM does not include this function but will be available in following update (eg: crouch), so if needed I can provide you this capsule scale function, where the character is scaled from top to bottom, so it stay on ground but clears ceiling.

    Please let me know if need any further help.

    Regards,
    Krull
     
  16. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    99
    Hey @Krull,

    just a quick question. I was about to import ECM into a new Unity 2019.1 project and I noticed that you also import the ProjectSettings folder (unless you deselect that). A warning comes from Unity that you are checking out an entire project. What should I do? Just uncheck ProjectSettings? After all, I don't want to overwrite all my settings.

    Thank you in advance.

    Best Regards
     
  17. Krull

    Krull

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

    Feel free to ignore the project settings while importing ECM, as those are not needed by ECM at all.

    The only reason the package contains the project settings is because its listed on store as a system, and that category adds the project settings to the package when submitted to store.

    Hope this helps you, however if have any questions, please let me know it.

    Kind regards,
    Oscar
     
  18. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    99
    Hey @Krull,

    thanks for the explanation. Now, of course, that makes sense. :)
     
  19. Krull

    Krull

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

    Great! glad I was able to help you.

    Regards,
    Krull
     
  20. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    37
    Hey @Krull,

    Thank you very much for that wealth of information!
     
  21. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @Squeyed,

    No problem, glad to help you, please let me know if need any further help :)

    Regards,
    Krull
     
  22. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Hello- I've been using ECM 1.4.6 on a long term project- everything works perfectly but randomly my ECM character will fall through floor box colliders- I can't reproduce it at all- it will just randomly happen while play testing the game- if I go back and try to reproduce it I cannot-

    The player isn't moving at high speeds-just the normal fall speed-

    All the floors use BoxColliders, no mesh colliders at all- the only pattern I've seen is that it happens when the player is sliding down a wall then they will just go through the floor with no collision at all- there's no gap between the wall collider and the floor as they are snapped to each other-

    I've done all the things you are supposed to do with Unity Physics settings to try and mitigate this issue but it still randomly happens :(

    Would upgrading to the newest version of ECM potentially fix this issue?

    Thank you.
     
  23. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @mdotstrange

    Its nice to hear from you!, happy to know you still using ECM with your projects :D

    mmm, well about your issue, some times when using unity primitive colliders its best to overlap them in their union in order prevent this kind of issues, and please make sure the collider is not set to convex as I noted some issues with this setting, additionally could be caused by a misplaced layer id.

    By other hand, I strongly suggest you to update to latest v1.6 of ECM as it was a major (mostly new project) and a much much more advanced and functional than the v1.4.6 was.

    I developed it to be easy to upgrade, however as always, please backup your project before upgrade and when importing ECM, please discard the package project settings as those are not required by ECM at all and will overwrite your project current settings.

    I received your email, I will review the included script file and send you an update version for it :)

    Best regards,
    Oscar
     
    imaginationrabbit likes this.
  24. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Thank you for the quick response- I will overlap my box colliders- I double checked the layer id's and they are correct-

    I've updated to the newest version of ECM and looking forward to getting the updated Controller script you provided years ago- thank you :)
     
  25. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Thank you for sending the updated custom controller script - I now have everything working again- I haven't seen the falling through the collider issue yet and I hope it never happens again :)

    Thanks again for the great asset and great support.
     
  26. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @mdotstrange

    Great! thank you for the update, glad I was able to help you.

    Thank you! :)

    Best regards,
    Oscar
     
    imaginationrabbit likes this.
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello,

    A new updated version for Easy Character Movement has gone live! The version 1.7 among other features adds support for crouching behavior, Pause / Resume character physical interactions, 2D Example, FPS Headbob example, etc.

    Here I attach the list of full changes:

    *** PLEASE BACKUP BEFORE UPDATE.

    - Added crouch support.

    - Added SetCapsuleDimensions method to CharacterMovement component. This make easy to modify capsule dimensions at run-time (eg: scale, crouch, etc).

    - Slightly modified FPS Camera hierarchy, added Camera_Pivot, and Camera is now child of this Camera_Pivot. This allows to perform camera animation easily. The HeadBob example make use of this Camera_Pivot to animate camera.

    - Added FPS HeadBob example. This shows how to perform headbob animation.

    - Added 2D Example. This shows how configure an ECM character for a typical 2D sidescroller.

    - BaseCharacterController Move method is now virtual.

    - BaseCharacterController Jump, MidAirJump and UpdateJumpTimer are now virtual, this allows to modify default jump mechanics.

    - Fixed a bug related to mid air jump. This caused the character to get stuck if mid air jump occurs near ground.

    - Fixed a bug in MouseLook component when the smooth option is toggled. This caused the camera bypass the clamp settings.

    - Updated documentation.


    Please don’t hesitate to post any questions, doubts or issues on the package. I’ll be happy to help you.
    - Krull
     
  28. Filhanteraren

    Filhanteraren

    Joined:
    May 14, 2014
    Posts:
    47
    Great to see crouch support. Is there any documentation or example to use it?
     
  29. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @Filhanteraren

    About the crouch support, there is not documentation yet :oops:, however the included demos shows how to use it.

    Actually it is pretty straightforward as ECM handle the crouch / un-crouch internally (collider resize, clearance check, etc.), all you need to set its Standing and Crouching capsule height, and use the input crouch property to toggle it, it expose the crouching state with the isCrouching property, this can be used to scale your model, feed your animator, etc.

    ECM Includes several examples to show how to handle your model crouching, for example the Ethan character uses an Animator to handle it, where you just feed the isCrouching property

    Code (csharp):
    1. animator.SetBool("Crouch", isCrouching);
    By other hand, the capsule is scaled (once again) in response to the isCrouching property, it uses an included example helper component CrouchingModelScaler, which scale the model as follows:

    Code (csharp):
    1.  
    2. private void ModelScale()
    3. {
    4.     var yScale = characterController.isCrouching
    5.         ? Mathf.Clamp01(characterController.crouchingHeight / characterController.standingHeight)
    6.         : 1.0f;
    7.  
    8.     modelTransform.localScale =  Vector3.MoveTowards(modelTransform.localScale, new Vector3(1.0f, yScale, 1.0f), scaleSpeed * Time.deltaTime);
    9. }
    10.  
    Hope this helps you, however do not hesitate to message me back if have any further questions

    Best regards,
    Krull
     
  30. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    290
    Would this controller be able to support proning? Is there any plans of adding it out of the box?

    Thanks
     
    Willbkool_FPCS likes this.
  31. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @giraffe1

    Well while not out of the box, and while the current version (1.7) requires the capsule to be vertical aligned (eg: not rotated) you can implement a proning mechanic, handling it similar to a crouch, I mean, when your character lies down, you scale your capsule height to match yours prone model height , and orients your model along the ground surface using the included OrientModeltoGround component.

    Worth note the following 1.8 will allow capsule (eg: rotation to follow terrain orientation), however the proning mechanic remains the same as above, with the only difference of align your character (capsule included) along the ground and not just its model.

    I can add an example of the above method in the next ECM update (1.8)

    Best regards,
    Krull
     
    giraffe1 and Willbkool_FPCS like this.
  32. Amadeu

    Amadeu

    Joined:
    Dec 11, 2014
    Posts:
    9
    Hi Oscar! How are you? I hope that everything is fine in your side!
    I'm writing you because I've been triggered ( xD) by one of your answer to a review:

    "however worth note the following update (1.8) among other features, will add support for arbitrary character rotation and gravity direction."

    Just wondering... can you give us an insight about the other new features that you are planning to include in the following update?? thanks in advance and a big hug for you!!
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hey @Amadeu!

    Happy to hear from you! :D

    Well yes, as commented in the quoted reply, the following update (v1.8) will add the following features:

    - Arbitrary character rotation, eg: Mario galaxy like ( keeping all distances! :) )
    - Custom gravity direction.
    - Updated OrientToGround helper component to fully follow the 'terrain' and not just its model.
    - Updated jump behavior, adding 'tolerance' timers. I mean, a timer to allow the jump even when the character is not grounded, and the same when landing, a kind of 'lock down' or recovery timer in order to be able to jump again.
    - Additional examples.
    - Add a 'walktrhorugh' guide in order to make easier to create / get familiar with the ECM custom controller methodology.

    By other hand, If you are looking / needing for something in particular, please let me know it and see if could squeeze it in the update.

    A big hug back you to! take care,
    Oscar
     
  34. Amadeu

    Amadeu

    Joined:
    Dec 11, 2014
    Posts:
    9
    This sounds AWESOME Oscar, looking forward for it! I can see myself using the jump tolerance timers from minute 0, but also I'll think in something to use the arbitrary character rotation and the custom gravity direction too =)

    And thanks for the offering! it means a lot, but I don't want to give you more work, you are already doing a lot!

    Right now I'm enjoying a paternity leave, so I'll use part of this time to finish sculpting the model for the main character and then I have a friend that will help me to add the following features:

    - Sprint (runs faster during a certain amount of time)
    - 2nd jump (like in Mario 64, if you jump and then you press jump again just when grounding the 2nd jump is higher)
    - Glide (slow falling like in Breath of the Wild)
    - A system to unlock through Playmaker the previous features + the double jump one (for character progression)
    - A proper animator with custom animations for all the previous movements
    As far as know is not as hard to do, thanks to the great foundations that you are offering with your asset and how clean and well organised your code is, so let's see if I have everything running properly for the next February / March =)

    And that's it, again thanks for the amazing work that you are doing and keep rocking!

    Best regards,
    Amadeu
     
  35. Kellyrayj

    Kellyrayj

    Joined:
    Aug 29, 2011
    Posts:
    933
    @Krull Hi Krull! It would be super awesome to have a quick feature to override the velocity at any given frame. I have a grappling hook feature and a swing feature and the way I got it to work is by turning off the character movement script when those conditions are met.
     
  36. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @Kellyrayj,

    Thanks for suggestion!

    mmm, at lack of further information about your current implementation, it should be a matter of override the CalcDesiredVelocity as this is the method responsible of feed the desired velocity to the CharacterMovement Move method, which in order apply the movement.

    One thing to keep in mind, is in order for an ECM character to 'fly', you will need to toggle its property allowVerticalMovement otherwise it will discard its vertical velocity and keep it on x/z plane.

    Regards,
    Oscar
     
    Kellyrayj likes this.
  37. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @Amadeu

    Thank you for your support and kind comments, I really appreciate it! :D

    About the features for your Auri's Tales game , sounds really fun! I really liked the second jump idea, Ill try to squeeze at least some of those as examples in the following update, thanks!

    The reason of add most of 'extra' features as examples is because not all games would use / need it, and would like to keep 'base' controllers as light as possible.

    Un fuerte abrazo,
    Oscar
     
  38. nyobu

    nyobu

    Joined:
    Mar 9, 2017
    Posts:
    14
    I have Easy Character Movement and Character Movement Fundamentals.
    So I can not understand difference. I asked in Character Movement Fundamentals's thread.
    He answered me as far as he knew.
    So I want to hear your opinion.
    I think this question is difficult, but please.
     
  39. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @nyobu

    Well, this is somewhat difficult question, like other Character Controllers on the store, ECM and CMF
    are different approaches to a common problem, both are pretty capable and Jan accurately enumerated the current feature differences between both packages.

    Having said that, while at surface both share similar core features, I think its difference is in its implementation and how you work with each one.

    ECM has been designed for easy extensibility and to serve as a base where you can build your core game mechanics on top of its 'base' controllers (BaseCharacterController, BaseAgentController, BaseFirstPersonController), for example, in ECM you create a custom controller extending one of the 'base' controllers, and extend / modify its core methods to suit your game needs, while still retain all the features ECM controllers have to offer.

    As Jan, I suggest you try both systems, and decide which work methodology is the better for your game or the one you like the most to work with, because as I commented, both are pretty solid and capable systems.

    In the end, ill say the difference is the blue cap :p

    Please do not hesitate to message me back (here or support email), if have further questions or need any help with ECM.

    Kind regards,
    Oscar
     
  40. nyobu

    nyobu

    Joined:
    Mar 9, 2017
    Posts:
    14
    Thank you!
    I bought both. I will try them again.
    Really thank you!!
     
  41. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @nyobu

    Glad I was able to help you, please let me know if have any question or need help with ECM.

    Regards,
    Oscar
     
  42. Mars91

    Mars91

    Joined:
    Mar 6, 2012
    Posts:
    564
    Hi I emailed you with a queation about stepoffset.
     
  43. davdeo

    davdeo

    Joined:
    Aug 11, 2019
    Posts:
    4
    Hey @Krull,
    is there a way to prevent falling off any kind of ledge? (even if they are rounded - see attatched image)
    I have an Island and the ledges are all rounded and i would like to prevent falling down, but when my ship lands on the side of the island and moves out a plank, i would like to be able to walk onto it (it is not possible to surround my island with invisible walls)

    Regards
    David
     

    Attached Files:

  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hi @davdeo

    Well by default the only way to prevent it is using the BaseAgentController and bake your NavMesh without Off-Mesh Link, this way the character would not get a path at the target position, and wont move.

    You can use a similar approach, in the CalcDesiredVelocity method, you can use your future position eg: currentPosition + desiredVelocity * Time.detlaTime, then use this targetPosition to check if is on 'valid ground' here you can use NavMesh and sample this future position to check if it lies on walkable ground or not.

    An alternative method without NavMesh, is follow the same procedure described above, but use the CharacterMovement ComputeGroundHit method, to check if the future position is walkable ground or not.

    Once you deiced if your next position is valid or not, is youll need to clamp (zero out) the desired velocity to stop character movement.

    Hope this helps you.

    Regards,
    Oscar
     
  45. mookfasa

    mookfasa

    Joined:
    Dec 21, 2016
    Posts:
    39
    Hey @Krull

    I am trying to get my character to up when I am inside a trigger. I am accessing the Custom Character Controller like this.

    ccc = player.transform.GetComponent<ECM.Examples.CustomCharacterController>();
    ccc.jump = true;

    I am guessing because in the Custom Character Controller the jump is being overridden by this?
    jump = Input.GetButton("Jump");

    Is there a way I can override it so anytime I call jump the player will jump?

    Thanks, moo
     
  46. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    I was hoping you could help me out.
    I am having an issue when I add another Camera (depth only for weapons). When I crouch I can set the scale between 1 and 2 to compensate for the Camera_Pivot moving between 1 and 0.5, but it's jerky. Also the weapon no longer follows the Camera until I uncrouch.

     
  47. Krull

    Krull

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

    Yes, you are correct, in order to controll a character from an external script and no your custom controller, in your custom controller youll need to remove the input code from the HandleInput method.

    eg: In your custom controller (the one extends BaseCharacterController) remove the input code from HandleInput method

    Code (csharp):
    1.  
    2. protected override void HandleInput()
    3. {
    4.    // Remove any imput code from here...
    5. }
    6.  
    This way you can use the ECM moveDirection, Jump, Pause, etc input commands.

    Best regards,
    Oscar
     
  48. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    I don't want to change anything about the movement. It is simply crouching. Since the Y scale changes on the Camera_Pivot, everything else below will be affected as well. So, when I attach a second camera for my arms, the arms get squashed.
    I attempted to fix this by scaling up the second camera (arms) while the Camera_Pivot scales down. It is very jerky. Is there another way to update the scale or "crouch" in a different manner?
     
  49. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    708
    Hello @jnbbender

    The default FPS Rig, by default it works as follows, the character's root, will handle the Yaw rotation, the Camera_Pivot by default does not add any particular movement / rotation to its child Camera object, however this pivot is used to animate it (HeadBob example) to add a Roll animation, last but not least, the Camera is expected to handle the Pitch.

    - ECM_FirstPerson -> Yaw
    - Camera_Pivot -> Roll / Height (if needed)
    - Camera -> Pitch


    The crouch is controlled in the BaseFirstPersonController AnimateView as follows:

    Code (csharp):
    1.  
    2. protected virtual void AnimateView()
    3. {
    4.     // Scale camera pivot to simulate crouching
    5.  
    6.     var yScale = isCrouching ? Mathf.Clamp01(crouchingHeight / standingHeight) : 1.0f;
    7.  
    8.     cameraPivotTransform.localScale = Vector3.MoveTowards(cameraPivotTransform.localScale,
    9.         new Vector3(1.0f, yScale, 1.0f), 5.0f * Time.deltaTime);
    10. }
    11.  
    You can modify the way it crouches, in your custom controller override the AnimateView method and add your custom crouch code in there, for example, handled by animator.

    Please take a look at the FPS HeadBob Example scene (Easy Character Movement\Examples\Scenes) and its custom controller 'FPS_CustomController' (Easy Character Movement\Examples\Scripts\Controllers) example. While it does not crouch, it shows how to modify the camera animation, in this case to simulate a headbob using animator.

    Please do not hesitate to message me if need any further help.

    Best regards,
    Oscar
     
  50. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    479
    Thanks for your response above.
    Another question for you though. I am looking for the right place to add a footstep script. I am using the stepOffset field in BaseGroundDetection to determine my steps. I'm sure this is not what this field was meant for. Can anyone point me in the right direction for adding footsteps to the framework?

    Also, I am trying to setup Crouch so that it works on GetKeyDown() so it is a toggling crouch. But in HandleInput on BaseFirstPersonController, when I change
    Code (CSharp):
    1. Input.GetKey(KeyCode.C)
    to

    Code (CSharp):
    1. Input.GetKeyDown(KeyCode.C)
    I lose all crouch capability.