Search Unity

[RELEASED] Easy Character Movement

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

  1. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    does ecm2 has RB2D or 2D tiles and all those support?
     
  2. Krull

    Krull

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

    Unfortunately no,as internally 2D and 3D uses different physics engines without a direct port between both.

    Regards,
    Krull
     
    Last edited: Jul 21, 2021
  3. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    23
    Snag.gif
    Had this problem as well. It doesn't seem related to wall grabbing or friction at all, as it happens fresh out of the box on a clean project with no code editing, using the ECM_BaseCharacterController on the main Demo scene. It has to do with the ground limit and how ground is detected I believe, as the ground detection does not "look ahead". ECM2 solves the problem but that doesn't really help us ECM users, I've mentioned it before. Once where I was getting "snagged" jumping over and colliding with Rigidbody boxes and the same as you when moving forward and jumping or double jumping up against steep slopes. It seems to happen at high angles between 80-89 degrees. The only thing that seems to work for me is to make the ground limit lower, or make the ground limit and slope limit the same value.
     
    Last edited: Aug 13, 2021
  4. Krull

    Krull

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

    A few words about this, ECM2 uses a different algorithm for its 'character controller' (CharacterMovement) than ECM, ECM2 at great sight implements a continuous collision algorithm (look ahead) so it can better decide how should proceed when a collision occurs, giving more flawless movement as it actually check the full desired movement.

    By other hand the current ECM algorithm uses at great sight basically 'fix' the position given by PhysX (since it allows inter-penetration) and then test the ground below the character in order to decide how it should move.

    Now having said that and without giving further details, it's worth saying I have not forgotten ECM users :D, actually my plan about ECM and ECM2 is to keep both systems equally capable (technically speaking).

    Where ECM will remain as a lower level version, NOT technically but 'more to the metal version' so users can use it to build their game mechanics on top of it their own way, while ECM2 adds a higher level layer on top of its functionality offering many great features out of the box like events, physics volumes, movement modes, buoyancy, etc. So users who decide to opt for ECM2 will build their own game mechanics with the added flexibility provided by ECM2.

    In the end my goal is both packages will share a common CharacterController equally capable!

    Regards,
    Krull
     
  5. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    23
    I understand, but how do you fix this "snagging" issue with ECM?? I love ECM it's a great character controller! This is the only real problem I've had with it.
     
    Last edited: Aug 14, 2021
    VincentAbert likes this.
  6. Krull

    Krull

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

    As you already noticed, just setting the ground limit a lower (eg: the default value of 60 degrees) solves this, but keep in mind the CharacterMovement slopeLimit must be less than or equal to ground detection Ground Limit.

    Ideally yes these values should be unified (same values) and actually in a future update I plan to merge the GroundDetection class into the CharacterMovement class pretty much like I did with ECM2, so this will make things clearer and easier to set up a character.

    Having said that, I actually tried to reproduce the issue setting the Ground Limit to 89 and could not, so I would appreciate it if you could share with me a test scene or steps needed to reproduce it.

    Regards,
    Krull
     
  7. dillonburton85

    dillonburton85

    Joined:
    Mar 24, 2014
    Posts:
    7
    Just wanted to jump in here and say I'm also experiencing literally the exact same wall friction issue as @Amo-deus with ECM. The strange part about it is that sometimes it happens, and sometimes it doesn't. When it does start happening, it happens on all walls. Replaying and re-loading the scene does nothing. When I restart Unity, it goes back to normal for about 10 or 15 plays, then goes right back to doing it again. Different settings don't seem to change anything.

    I've narrowed it down to ECM, but really have no idea why this could be happening. The only reason I can possibly think is some conflict with ECM and quick scene reloading, maybe there is something there that is persisting.

    Otherwise, amazing asset!
     
  8. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hello @dillonburton85

    Mmm, thats quite a strange bug, and honestly I have not seen this or been reported before in the long time ECM has been on store.

    Having said that, I appreciate if you and @Amo-deus, could provide additional information, in order to better help you. Please share with me your character settings (being one of the most important, your capsule center) and if possible a basic test scene showing the issue so I can be able to track it.

    Thank you! :D

    Regards,
    Krull
     
  9. Amo-deus

    Amo-deus

    Joined:
    Jul 27, 2015
    Posts:
    23
    Hi Krull.

    For me all I've done is created a new project and opened the examples demo. Using the ECM_BaseCharacterController in the scene with its default values and slide on steep slopes turned on. Then create a cube or wall and angle it just 5 degrees. Jump up against the angled wall, but make sure that you are actively pushing the character towards it and not just hitting jump. That's pretty much it for me. I've not experienced it for every wall like @dillonburton85 just very steep ones on a decline, but it depends on the settings probably.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      348 KB
      Views:
      270
    • 2.png
      2.png
      File size:
      365 KB
      Views:
      274
    Krull likes this.
  10. Krull

    Krull

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

    Thank you for sharing this with me as it will definitely help me to isolate and solve the issue.

    Regards,
    Krull
     
    Amo-deus likes this.
  11. socialtrens

    socialtrens

    Joined:
    Oct 23, 2017
    Posts:
    65
    Still no Unity Cinemachine example?
     
  12. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hello @socialtrens,

    Unfortunately not for original ECM (yet), however ECM2 includes several Cinemachine examples along Bolt Integration and much more features and over 30 examples, but the downside being a completely new product written from ground up, there is not a direct port for current ECM projects.

    Regards,
    Oscar
     
  13. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hi @Krull !
    I'm having another issue with ECM 1 :


    Basically you can see at the start the character jumps a "normal" amount, but when she comes in contact with that top cube, she gets thrown in the air (presumably because of the small torque/velocity of the rigidbody) with a very unexpectedly strong force. It should be quite simple to reproduce, by stacking two boxes on top of one another, and simply jumping while being in contact with the boxes. (for context, each box is around 150 Kg, and the character 45 Kg)
     
  14. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hey @VincentAbert

    Mmm, from your video I think it could be related to the snap-to ground feature and or how PhysX resolves the collision. A few things to try:

    First, related to snap to ground and in particular to ledge offset, try increasing it value an see if still happens, also make sure your cubes are on ground mask (if walkables) and snap to ground feature is enabled (Snap Strength 0.5)

    Another option is try setting the character mass to 1, as actually PhysX behaves better with lower values.

    If it is related to penetration, please try setting your character's rigidbody maxDepenetrationVelocity to 1, so if it is penetration related, this should make it obvious.

    I tested stacking two default unity cubes with a mass of 150, and Character's mass 1 and 50 (default ECM character) and could not reproduce it, so please let me know if this helps you.

    Kind Regards,
    Krull
     
  15. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Thank you for your reply !
    Sadly those suggestions didn't change the issue, as it was set up properly... But I'm pretty sure I found the culprit : if you set the cubes' rigidbodies mode to interpolate, I think you should get the issue as well. Setting the interpolation back to "none" fixes it, but then when the player pushes them (by simply walking into them), their movement is stuttering.

    Have a nice day.
     
    Marco-Sperling likes this.
  16. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Same issue here in our project. Character gets thrown into the air when approaching a rigidbody that is set to "interpolate" for the same reason (stuttering).
     
    VincentAbert likes this.
  17. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @VincentAbert, @Marco-Sperling

    I performed several tests trying to reproduce the issue with a default ECM character and default ECM installation and honestly could not.

    Do you have the ECM mod to allow use of regular rigidbodies as platforms? if so, this could be the cause where the character tries to 'snap' to the rigidbody acting as a platform, and could cause 2 issues, one try to snap to a 'invalid' position causing inter-penetration so PhysX will resolve with an impulse, or the character is being pulled by the cube acting as a platform.

    I suggest try to disable this mod and test it, if so, you could use tags to differentiate real dynamic platforms (ice blocks if I remember correctly), to other non-rideable dynamic objects.

    Regards,
    Krull
     
    VincentAbert likes this.
  18. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hi,

    After a bit more testing, that was exactly it, just checking against a specific tag or layer when the "ground" is found to be non-kinematic fixes the issue. Thank you for your help !

    Vincent
     
  19. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @VincentAbert ,

    Awesome! happy to hear it and glad I was able to help!

    Kind regards,
    Krull
     
  20. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hello ! I have some new (related) issue with dynamic platforms. As you can see in the video (animation disabled for better readability), the character's velocity is influenced by the dynamic rigidbody, but there is a LOT of sliding around. It seems to be somewhat connected to the character's mass, but even with the tiniest mass there is some amount of sliding, which makes me think the mass simply amplifies another issue.

    Here is my SnapToPlatform method, based on the modifications you had sent me a while back.

    Code (CSharp):
    1. private void SnapToPlatform(ref Vector3 probingPosition, ref Quaternion probingRotation)
    2.         {
    3.             // If we are leaving ground, return
    4.  
    5.             if (_performGroundDetection == false || _forceUnground || _forceUngroundTimer > 0.0f)
    6.                 return;
    7.  
    8.             // Check where is character standing on
    9.  
    10.             GroundHit hitInfo;
    11.             if (!ComputeGroundHit(probingPosition, probingRotation, out hitInfo, groundDetection.castDistance))
    12.                 return;
    13.  
    14.             // If not on a platform, return
    15.  
    16.             var otherRigidbody = hitInfo.groundRigidbody;
    17.             if (otherRigidbody == null || (!otherRigidbody.isKinematic && !otherRigidbody.CompareTag("Dynamic Platform")))
    18.                 return;
    19.  
    20.             // On a platform...
    21.             // Compute target grounded position
    22.  
    23.             var up = probingRotation * Vector3.up;
    24.             var groundedPosition = probingPosition - up * hitInfo.groundDistance;
    25.  
    26.             // Update character's velocity and snap to platform
    27.  
    28.             var pointVelocity = otherRigidbody.GetPointVelocity(groundedPosition);
    29.             cachedRigidbody.velocity = velocity + pointVelocity;
    30.  
    31.             var deltaVelocity = pointVelocity - platformVelocity;
    32.             groundedPosition += Vector3.ProjectOnPlane(deltaVelocity, up) * Time.deltaTime;
    33.  
    34.             // On ledge 'solid' side, compute a flattened snap point
    35.  
    36.             if (hitInfo.isOnLedgeSolidSide)
    37.                 groundedPosition = MathLibrary.ProjectPointOnPlane(groundedPosition, hitInfo.groundPoint, up);
    38.  
    39.             // Update character's position
    40.  
    41.             probingPosition = groundedPosition;
    42.  
    43.             // On rotating platform, update character's rotation (platformUpdatesRotation == true)
    44.  
    45.             if (platformUpdatesRotation == false || otherRigidbody.angularVelocity == Vector3.zero)
    46.                 return;
    47.  
    48.             var yaw = Vector3.Project(otherRigidbody.angularVelocity, up);
    49.             var yawRotation = Quaternion.Euler(yaw * (Mathf.Rad2Deg * Time.deltaTime));
    50.  
    51.             probingRotation *= yawRotation;
    52.         }
    It still works great on animated platforms.

    EDIT : here is the video
     
    Last edited: Sep 22, 2021
  21. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    ;)
    Hi @VincentAbert,

    Ah yes, well by default ECM does not allow other dynamic rigidbodies to act as platforms, as internally it tries them as another 'character' and will try to slide character off the rigidbody.

    Having said that, it can be modified to let the character ride this as a regular kinematic platform, but will need to perform a few tests before providing you a solution as honestly I have not modified ECM core in a while!

    By other hand and without spill the beans (;)) as commented on a previous message (not sure if was here on ECM2 post), I do plan to have a equally capable motor with ECM and ECM2 but keep ECM as a lower level (aka more to the metal version) and ECM2 as a higher level layer with obviously more extra features like it already includes. And actually pretty close to showing something regarding this so please bear with me on this.

    Cheers,
    Krull
     
  22. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hi,

    Thanks for your response. I've been considering ECM2 for a while, but a lot of my system is now built around ECM1, not to mention a pretty complex custom controller that will be hell to adapt... So until I find use for a complete overhaul, I'd really like to stick to it. I don't mind waiting a bit if you can find a solution :)

    Thanks again for all your work !

    Vincent
     
    Krull likes this.
  23. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @VincentAbert,

    Yes, while ECM2 shares some similarities with ECM its a completely new product and unfortunately not a direct / transparent port from ECM to ECM2, so my recommendation is if your project is already in production keep ECM, however if starting a new project I definitely recommend ECM2!

    Regards,
    Krull
     
  24. Chilli

    Chilli

    Joined:
    Aug 12, 2012
    Posts:
    9
    Hey Krull,

    I've been trying to get some momentum-based movement working which is not really workout out too well.
    The main thing that I have been adjusting is the GroundFriction variable, and also played around a bit with Deceleration. What I've been doing is decreasing the GroundFriction variable if the player has been moving down a slope for a certain amount of time, but this doesnt really work in all cases. For example, this doesnt work well when moving up and down a bunch of smaller slopes with varying slope angles.
    I think this might be an issue because I have set the Slide Angle to be 45 and the Ground Detection to something like 75.
    Essentially I want the player to accelerate down a slope and then use the momentum gained to be able to climb steep slope (while also having a bit of control on when sliding back down if there isnt enough acceleration/momentum).
    Also, I'm not sure what the best way is to keep some of the control of sliding? Right now there's not really any option to have much control while you're sliding down a steep slope.

    It seems like a very case-specific issue, at least the momentum part. Is any of this available out of the box in ECM2?
     
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @Chilli,

    Mmm, ECM 1 by default when a character is sliding off a non-walkable surface ignores input to force the character to slide off the invalid object, do you mean like a slide ? ECM2 includes a typical FPS slide example, it is implemented as follows:

    When sliding, lowers ground friction and braking deceleration and apply an initial slide impulse, then while character is sliding keep applying gravity acceleration (projected along ground surface normal) so the character accelerates downhill, in this particular case, the sliding state exits once the character speed reaches a min threshold.

    I think you can try a similar approach in ECM, but not using a slide on a steep slope, because as commented this will disable your mobility, so it is better to apply an extra acceleration manually so you keep character movement.

    Regards,
    Krull
     
    Chilli likes this.
  26. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    hey btw did u ever get to finish the platformer game that you wanted to make with ECM?
     
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Unfortunately no because of different personal situations at that time, hopefully some day release it :)
     
  28. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hey Krull,

    Do you know how to stop the player from rotating towards the mouse position whenever I unpause the game?
    It's like it caches the rotation value when I'm moving the mouse around and when I set the timescale to 0 it completes the rotation, which is quite annoying.

    Just wondering if it's just how Unity works with the timescale or if there's anything I can do with your character controller.

    Thanks!
     
    Last edited: Nov 11, 2021
  29. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @EpicMcDude

    Ah yes, this happens because the mouse movement is not affected by the timescale, so to solve this issue you will need to prevent camera rotation while paused, for example in your custom controller (the one extending BaseFirstPersonController), override its UpdateView method as follows:

    Code (csharp):
    1.  
    2. protected override void RotateView()
    3. {
    4.     if (isPaused)
    5.         return;
    6.  
    7.     base.RotateView();
    8. }
    9.  
    This will disable camera rotation while the character is paused, from there you can change the condition for example, when the mouse cursor is unlocked or your game is paused, etc.

    Regards,
    Krull
     
    twitchfactor likes this.
  30. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Ahh I see, I'm having a tiny problem though, I'm experimenting with your FPS_CustomController script and I couldn't find the RotateView() method - I've added it in but it doesn't work when I pause the game either.
    I'm also using playmaker, which is just C# but visualized (I don't know C#), and I'm setting the IsPause bool to true but the rotation still keeps happening.

    upload_2021-11-8_2-2-52.png

    Should I make a new C# script inheriting from your BaseFirstPersonController or would I be able to keep using the example one? Or this doesn't have anything to do with it?

    Thank you!
     

    Attached Files:

  31. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    You can just add the code to the FPS_CustomController as it already inherit from BaseFirstPersonController.

    Another option if you are pausing your game setting Time.timeScale to 0, is directly modifying the MouseLook.cs in particular the LookRotation method to multiply the input values by timeScale. eg:

    Code (csharp):
    1.  
    2. public virtual void LookRotation(CharacterMovement movement, Transform cameraTransform)
    3. {
    4.     var yaw = Input.GetAxis("Mouse X") * lateralSensitivity * Time.timeScale;
    5.     var pitch = Input.GetAxis("Mouse Y") * verticalSensitivity * Time.timeScale;
    6.  
    7.     ...
    8.  
    Regards,
    Krull
     
    EpicMcDude likes this.
  32. exp626stitch

    exp626stitch

    Joined:
    Mar 31, 2020
    Posts:
    14
    @Krull I was wondering how to add two different things:
    1. How to add support for animations ex: Walking animation when walking, running animation while running.
    2. How to add more movements, like rolling, grappling, and crawling.

    I dont need full code, just some basic code and ideas to set me on my way.

    Thanks ahead of time!
     
  33. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @exp626stitch,

    Well ECM does not use animations or require you to animate your character in a special way, so you are free to animate your character as you prefer.

    However to keep your animation and character in sync, you read the character's state, e.g. isGrounded? isWalking? isRunning?, etc and use this to play the desired animation for the character's current state. Please take a look at the included "Custom Character Controller Examples" scene an its corresponding source code.

    ECM has been developed around inheritance, where you create a custom controller extending one of the included 'base' controllers, and use this custom controller to add your game required mechanics on top of ECM default functionality as you can see in the included examples.

    I suggest you start following the included Walkthrough to get familiar with all the ECM features. Its examples are fully commented and definitely will serve you as a starting point to better understand how to extend it and implement your custom game mechanics.

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

    Kind regards,
    Krull
     
  34. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hi Krull,

    I'm looking for a way to have the clearance check when crouching to ignore a layer, as I have a collider on my character's head bone that is keeping it from getting up as the clearance check will always get that collider.

    Thanks
     
  35. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @EpicMcDude

    The clearance check will test against objects in the overlapMask, so make sure your ignored object layer is not part of the overlapMask.

    Regards,
    Krull
     
    EpicMcDude likes this.
  36. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Oh man now I'm a bit confused. I don't know much C#, but from the comments on the code, the overlapMask will take the player's layer? My player is in the Player layer, while the head collider is in the Head layer. They don't interact with each other as I turned it off in the collision matrix but it's still stopping the controller from getting up. I probably misunderstood something...

    Thank you
     
  37. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Yes, the overlap mask is initialized using your character's collision layer matrix, and the clearance check will do an overlap test only against the objects in the overlap layers mask.

    You can modify the CharacterMovement OverlapCapsule function (line ~615) to ignore the overlapped collider attached rigidbody, so it will ignore all colliders attached to the character, as follows:

    Code (CSharp):
    1. private void OverlapCapsule(Vector3 bottom, Vector3 top, float radius, out int overlapCount,
    2.     LayerMask overlappingMask, QueryTriggerInteraction queryTriggerInteraction)
    3. {
    4.     var colliderCount = Physics.OverlapCapsuleNonAlloc(bottom, top, radius, OverlappedColliders,
    5.         overlappingMask, queryTriggerInteraction);
    6.  
    7.     overlapCount = colliderCount;
    8.     for (var i = 0; i < colliderCount; i++)
    9.     {
    10.         var overlappedCollider = OverlappedColliders[i];
    11.         if (overlappedCollider == capsuleCollider || overlappedCollider.attachedRigidbody == cachedRigidbody)
    12.         {
    13.             if (i < --overlapCount)
    14.                 OverlappedColliders[i] = OverlappedColliders[overlapCount];
    15.         }
    16.     }
    17. }
    This should solve your issue.

    Regards,
    Krull
     
    EpicMcDude likes this.
  38. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Thank you, that did indeed fix it!
     
  39. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Awesome, glad I could help!
     
    EpicMcDude likes this.
  40. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Hello, just bought this. But on importing it say it's a project so importing will overwrite project setting which is not good practice. Can you update it to just import normally like other assets ?
    For now the safe workaround will be making a new project, import your asset, then export to a package then import to my current project.
     
  41. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    In my opinion, easiest way is to just disable the folder with all project settings on import. You can untick it and it won't overwrite any layers, tags, etc.
     
    Krull and Spikebor like this.
  42. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Thanks, good to know!
     
    Pixelith likes this.
  43. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hello !

    It's been a few months, but recently I have been needing this feature again, and I was wondering whether you had the time to run the tests you were talking about to have ECM work on non-kinematic platforms (filtered via tag).

    Thank you,

    Vincent.
     
  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hey @VincentAbert

    Nice to hear from you :),

    Well while not updated ECM1 yet, to support non-kinematic rigidbodies as moving platforms, you will need to modify the CharacterMovement source code, in particular the DetectGround function (line ~949) where it allow only kinematic rigidbodies, replacing the if / else, as follows:

    Code (csharp):
    1. isOnPlatform = true;
    2. platformVelocity = otherRigidbody.GetPointVelocity(groundPoint);
    3. platformAngularVelocity = Vector3.Project(otherRigidbody.angularVelocity, up);
    To filter by tag, you will need to check in there too, so it allows only allowed ones.

    Probably not the solution you wanted to hear, but have you checked my other character controller? in particular the latest Character Movement (included in ECM2) I suggest this as its low-level character controller (like ECM1) really easy to use and its closer to ECM1, it actually includes as one of its examples a character controller pretty similar to ECM1 BaseCharacterController, but with many many advanced over it.

    Let me know if I can help you any further.
     
  45. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    301
    The default FPS character in ECM2 feels really floaty? What is the correct setting to tweak to make it feel like a standard FPS controller?
     
  46. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    It uses realistic values by default (i.e. -9.8 gravity), so like physics, its dependant of accurate level scale, etc. The easiest way to feel it more responsive is incrementing its gravity magnitude, i.e. a value of 30 should give you more snappy feel.

    Also make sure to adjust the jump impulse accordly.
     
    giraffe1 likes this.
  47. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hey Krull,

    Have just a question regarding ECM - I'm really enjoying using this so far.

    How would I be able to do a lock-on system with the FPS component? I.e. have the camera snap to a target and rotate the capsule and camera towards the target. So far I can't seem to have both do this, I haven't look into this in-depth but wanted to hear your thoughts first.

    I also wanted to take control away from the player camera, this pretty much related to the above, but basically pause the input of mouse rotation and then resume from where it was locked onto. Right now, once I remove the control of the rotation and give control back, the character will rotate towards it's last position before I took away control, snapping the camera really fast onto the spot. How could I fix this?

    Thank you!
     
  48. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @EpicMcDude,

    The FPS rig works as follows, the yaw is handled by character's rotation (ie: movement.rotation *= yawRotation) while the pitch rotation is applied to the cameraTransform, this happens in the MouseLook LookRotation method and is called in the BaseFirstPersonCharacter UpdateRotation method.

    To toggle mouse look and other camera look, in your custom controller (the one extending BaseFirstPersonController) you should override the UpdateRotation(), this will easily let you do regular mouse look or any other 'state' your camera needs, for example:

    Code (CSharp):
    1. public bool doRegularMovement = true;
    2.  
    3. protected override void UpdateRotation()
    4. {
    5.     if (doRegularMovement)
    6.     {
    7.         RotateView();
    8.     }
    9.     else
    10.     {
    11.         // Do other camera states here...
    12.  
    13.     }
    14. }
    This will let you toggle regular movement or other as needed.

    Regards,
    Krull
     
    EpicMcDude likes this.
  49. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hi Krull,

    Thank you for your help. I just remembered this is quite similar to an issue I was having in November last year, where the rotation would still snap after unpausing the game. (
    )
    This was fixed by multiplying the LookRotation sensitivities by Time.timeScale, it wouldn't snap to the previous place after that.

    However this time, it's still snapping after re-enabling RotateView.

    upload_2022-6-3_2-4-33.png

    Taking away mouse control works fine since it's only that line of code, but then I just want to smoothly reattach mouse control to the character and camera from the point it was looking at.

    To extend on doing other camera states on the "else" statement in your example code, I'm not sure what I could do since I'm not a programmer, that's why I just went with a return statement.
     

    Attached Files:

  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    I'm sorry but I am not fully understanding your current issue as halting the RotateView function call should stop mouse update as the mouse rotation is fully handled by the mouseLook.LookRotation function only (called in RotateView) and is this function the one who does first person rotation.

    To better help you could you set up a basic scene so I can take a look at the issue?

    In the meantime, you can try pausing your character (set BaseCharacterController pause property to false) when the game pauses, so it wont update any rotation and also make sure your time scale is set to 0 when paused.

    Here is the previous mod you commented:

    Code (csharp):
    1. public virtual void LookRotation(CharacterMovement movement, Transform cameraTransform)
    2. {
    3.     var yaw = Input.GetAxis("Mouse X") * Time.timeScale * lateralSensitivity;
    4.     var pitch = Input.GetAxis("Mouse Y") * Time.timeScale * verticalSensitivity;
    5.  
    6.     // Extra function code (not relevant)
    7. }
    Regards,
    Krull