Search Unity

[Released] Kinematic Character Controller

Discussion in 'Assets and Asset Store' started by PhilSA, Sep 29, 2017.

  1. headcoach_

    headcoach_

    Joined:
    Jul 25, 2020
    Posts:
    3
    Hi is there a reason why frame by frame interpolation is done in late update? This essentially breaks animation IK because the animation loop is handled between update and late update. Also random side note but, support for using different physics scenes would be nice
     
  2. Olog555

    Olog555

    Joined:
    Aug 20, 2017
    Posts:
    6
    I would like to know when I have LedgeAndDenivelationHandling enabled.
    I fall off the surface and the force guides me correctly, but the problem is that I can't cling to ledges. If I go to the edge, they will push me out.
    If I disable this option everything is more or less fine, but the following problem is added. When I fall from the surface, I am pulled sharply down and only slightly in the right direction. How to fix it? So that I fall with the correct acceleration and at the same time I can cling to surfaces (walk along the edge).
     
    Last edited: Feb 2, 2022
  3. ozodic

    ozodic

    Joined:
    Jan 3, 2019
    Posts:
    6
    is there a way to bypass interpolation for objects with PhysicsMover attached?
     
  4. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @PhilSA Hey, thank you very much for writing this character controller! It's the bee's knees! :)

    Everything seems to work great so far, the only thing we noticed is a bug regarding ledge detection in the latest version (3.4.3). It just doesn't work reliably.

    To test this we have a simple series of cubes. We put the player character on top and move it slowly close to the edge and beyond.

    (The radius of the character capsule is 0.5 and the MaxStableDistanceFromLedge is 0.25)



    Sometimes the capsule will slide over the ledge once it's past the 25cm and fall gracefully to the ground. Which is really neat! However it only happens about 25% of the time.

    The other times the capsule will just stick to the edge all the way until it looks like it's floating in the air before finally falling down to the ground (once it's pushed past its radius).

    I saw in the latest release notes you did something about the ledge detection and that probably broke something else in the system. Could you please take a look at this? Cheers! :)

    Actually regarding ledge sliding detection, do you think it would be possible to add a public setting for "how high must a ledge be to trigger the slide-and-fall" ?

    In other words if the player stands on the edge of a small step it wouldn't necessarily make sense to make it slide and fall. On the other hand if the ground beyond the ledge is say 1 meter down, then it would make sense to trigger the slide-and-fall behaviour. You probably already have a setting for this but I can't see it on the KinematicCharacterMotor component. Maybe I'm not looking at the right place?
     
  5. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    56
    I'm also experiencing this for the first time, I've been using the plugin for a few months and decided to add it to a new side project of mine, and as my character walks up slopes, if I push into the edge, they stick to it for a while until they finally pop off. Moving straight off a ledge (the same direction as the ledge normal) doesn't have any issues, but the moment I go diagonally into a ledge, it stays stuck to it for about a second, or if I stop moving and start again it moves off.

    It's worth noting I have not had this happen with flat ground, only with going up slopes
     
  6. LooksCozyLabs

    LooksCozyLabs

    Joined:
    Feb 18, 2021
    Posts:
    2
    Hi there, first off I love this asset! It's perfect for my characters so thank you!

    What would be the recommended setup for implementing a kinematic object with this? Say a ball you throw that needs to bounce off the walls, ground, other balls, and characters (KCC Motor/Controller) but not push the characters whatsoever?

    Right now I have the objects using a similar setup to characters and grounded movement is fine. However when they collide in the air, the object or character on the bottom is pushed down and away while the character or object above it maintains its velocity (expected kinematic behavior). Is there a way to set priority of this simulated collision to say which objects get pushed? I'm assuming is coming from the motor component.
     
  7. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    I bought this and realize this is the best thing in the world, thank you dev!
     
  8. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'm wondering what variable of KinematicCharacterMotorState should be sent to the client in order to re-simulate inputs? For example, there's a
    AttachedRigidbody, but we never send any object over the network, right?
     
  9. Vaeer

    Vaeer

    Joined:
    Feb 22, 2022
    Posts:
    8
    Hi, I think I got it, but how to make character stick to the dynamic (or any kind of) rigidbody while jumping mid air?
    What I need is basically make a character completely synced with another vehicles movement. So that includes stopping character mid-air when dynamic body stops or reversing characters movement when that body does it first. Simply changing gravity direction isn't enough as moving ground still gives momentum and doesn't force character to move with it mid-air.
    What I imagine is treating the rigidobody as it wasn't moving at all - character should rotate with it even upside down with no momentum at all, stick to its gravity like it was solid, static ground. Like it was the world that moved, not the vehicle. And I can't make the world move instead I'm afraid. How would you implement such feature?
    Obviously, that's not realistic physics, but that's the point.
     
    tonyomendoza likes this.
  10. PixelDough

    PixelDough

    Joined:
    Apr 27, 2018
    Posts:
    56
    The easiest way would likely be adding the ground's velocity to the character when you unground from it
     
  11. vicdotexe

    vicdotexe

    Joined:
    Apr 15, 2018
    Posts:
    1
    Hi, I'm loving this controller. I just wanted to throw my 2 cents in and suggest for the CharacterOverlap check, that the inflate parameter either be a vector2, or have an additional "inflateRadius" float parameter that just defaults to the first inflate entry if unused... that way there's an option to inflate the radius independently of the top and bottom of the capsule... dunno.. easy enough to implement myself, but thought it might be convenient for others.
     
  12. BourbonBristles

    BourbonBristles

    Joined:
    Jan 23, 2014
    Posts:
    7
    See AttachedRigidbodyOverride
    I think this should work for you, from a previous discussion in the forum: https://forum.unity.com/threads/released-kinematic-character-controller.497979/page-19#:~:text=bonzaiferroni said: ↑-,Movement around a platform seems pretty accurate even when it,only stop parenting once you reset "AttachedRigidbodyOverride" to null manually,-Last edited: May
     
    Last edited: Feb 28, 2022
  13. devhong993

    devhong993

    Joined:
    Sep 27, 2017
    Posts:
    2


    Hello. While using the framework, I noticed something strange. When I modified the character's MaxStableSlopeAngle to 45, the movement on the slope and spike became strange as shown in the video.

    The simplest solution is to change MaxStableSlopeAngle, but it seems that the problem will eventually arise elsewhere.

    Does anyone know about this issue?
     
  14. niftylius

    niftylius

    Joined:
    Feb 6, 2022
    Posts:
    2
    Hey, i've recently bought the kinematic character controller
    I am running into issues with unity transform.
    It sees like the Kinematic Character Motor breaks mirrors observers.

    NOTE: if i disable the motor when running and enable after the thing is in "client" or "client+server" mode then everything works perfectly

    My assumption is that Mirror takes over transform and the motor does the same.... Any work around?

    Ok after some investigation:
    A - i am doing client authoritative code for tests
    B - it seems that motor does not accept position changes ( scale sync works perfectly fine )
     
    Last edited: Feb 28, 2022
  15. niftylius

    niftylius

    Joined:
    Feb 6, 2022
    Posts:
    2
    This works for whatever reason

    private void Start() {
    if (hasAuthority) {
    GetComponent<KinematicCharacterMotor>().enabled = true;
    }
    }
     
  16. devhong993

    devhong993

    Joined:
    Sep 27, 2017
    Posts:
    2

    After debugging, I seem to have found the cause of the problem.

    'IsStable' repeated 'true' and 'false' in angles with some decimal places. Upon closer inspection, it seems to be a problem with the float of 'IsStableOnNormal'. (KinematicCharacterMotor.cs (line 1209))

    Code (CSharp):
    1.         private bool IsStableOnNormal(Vector3 normal)
    2.         {
    3.             return Vector3.Angle(_characterUp, normal) <= MaxStableSlopeAngle;
    4.         }
    So I modified it like this:

    Code (CSharp):
    1.         private bool IsStableOnNormal(Vector3 normal)
    2.         {
    3.             return Vector3.Angle(_characterUp, normal) < MaxStableSlopeAngle;
    4.         }
    Now it works fine!

    If it's not right to fix this, please let me know what's right.
     
  17. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    helo dev!

    does there exist any platformer examples for KCC asset like those found in your other DOTS controller Rival asset:
    https://philsa.github.io/rival-doc/samples

    the wall running and climbing character especially? it would be nice to see even pay addon package for extras for this KCC asset I would like to use KCC from this recent bundle to do what Rival can (minus performance boost)

    using DOTS i cant use my other assets for my prototypes i tinker
     
  18. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Hi bros, is there a proper way to change motor's velocity on demand ?
    like in an event I want to kill it's velocity
    Code (CSharp):
    1.         void ChangeVelocity(float multiply) {
    2.             motor.BaseVelocity *= multiply;
    3.             UpdateVelocity(ref motor.BaseVelocity, Time.deltaTime);
    4.         }
    5.  
    Does this work ?
    This will be called inside Character Controller.
     
  19. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    I dont think you have to or should call the UpdateVelocity function, just changing it directly like in the line above works for me :)
     
    Spikebor likes this.
  20. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    Thanks for clarifying.
     
    Vincent454 likes this.
  21. VirtualDestructor

    VirtualDestructor

    Joined:
    May 3, 2014
    Posts:
    44
    Thanks for this package. It fixed many issues I've had with character controllers for years, and it has worked out extremely well for me. Unfortunately, the latest version introduced seems to have introduced a bug for my character controller. When my character controller walks up a very small step (say even 1 cm), the character now flies into the air. Is anyone else having this issue? My investigation so far points to the changes to KinematicCharacterMotor.IsStableWithSpecialCases() being the culprit. Reverting back to the previous version of KCC seems to fix the problem.
     
  22. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    @PhilSA Can you fix the bugs introduced by the latest version?
     
  23. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    280
    My character movement is very jittery when she's walking on stair, how can I make it smoother ?
    Start at 0:20
     
  24. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    How do I implement KCC with Photon PUN. I get all sorts of sync issues. I can post code samples but somebody please help....
     
  25. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Essentially my issue is with moving the character across multiple clients. The movement appears to be shared amongst both players.
     
  26. gg_michael

    gg_michael

    Joined:
    Sep 24, 2012
    Posts:
    73
    Hey @PhilSA is it possible to get a list of where changes were made for the updates? Or like a diff? This is a fairly low-level package so I assume there are others like myself who have modified or refactored the motor components to better fit our specific project architectures. Would be nice to know where to go to start translating the fixes into my KCC components, as the update obviously only changes your builtin components. It's something I could do myself but I figure you maybe already have some similar list of changes you could share. Thanks!
     
  27. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Not sure how it is in PUN, in FishNet you have to disable the movement stuff, character controller, set rigidbody to kinematic on Non Owner players, so that only the owners can make the necessary movement.
     
  28. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Let me try and see if that works.
     
  29. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Not working... I can post a code sample but it didnt change
     
  30. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    I can't really help you with Mirror stuff as I don't understand it fully, i had issues with it myself. You could join the Fish Networking discord and they can try helping you out, even try out the networking solution itself might find it much simpler and easier to use.
     
    aidangig56 likes this.
  31. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Thank you @zKici I will definitely give it a shot. I hope the conversion process is smooth for my project from PUN to Fishnet
     
  32. devrandomzero

    devrandomzero

    Joined:
    Aug 2, 2020
    Posts:
    43
    Hi, I recently got KCC and it would be really cool to have this extras added to the asset.

    Thank you
     
  33. OveryonderStudios

    OveryonderStudios

    Joined:
    Feb 11, 2022
    Posts:
    3
    Any chance this is compatible with FinalIK?

    Having some issues grounding the feet using their FBBIK grounder solver.
     

    Attached Files:

  34. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    So I finally managed to KCC working in my project for synced movement with PUN. Essentially I had to do a check if the photonview.ismine is false, if so set movement and jump speeds to zero. Photon will sync everything else but for other players the movement speed should be disabled to prevent both players from moving with 1 input. If anyone has questions with PUN please let me know. I will do my best to help.
     
  35. echolink

    echolink

    Joined:
    Apr 30, 2014
    Posts:
    5
    Hi @PhilSA

    I try to create a moving platform in a ferris wheel form.
    In gif i attached :
    1. the yellow platform is implemented with physic mover, im using dotween and i set the goal position using next step from the Dotween evaluation.
    2. the ferris wheel currently using hinge join, so i cant hold any object. i try to implement PhysicsMover for it, but since i just rotate the parent rotation, i dont know its goal position. If i set it to current position then the result is very jittery.

    Is there a way to handle goal position if we dont really know the excact value? or are there a better implementation for this?
     

    Attached Files:

  36. ranaUK

    ranaUK

    Joined:
    Mar 1, 2017
    Posts:
    166
    Does anyone have any example of using NavMesh; or even the examples from V2 of this package (I really wish Unity would allow downloading of old package).

    Thanks in advance.
     
  37. JungaBoon

    JungaBoon

    Joined:
    Aug 4, 2020
    Posts:
    18
    Hi, is there a way to set this up without using the camera scripts? I wanted to use Cinemachine, but am stuck on Walkthrough Part 2 where it's setting up character movement.
     
  38. makaolachsiungca

    makaolachsiungca

    Joined:
    Sep 27, 2019
    Posts:
    31
    Hello,
    I'm having trouble walking up the stairs.
    When the radius of the Capsule collider is too small, causing a very bumpy phenomenon when walking on the stairs.
    Hopefully there will be a function for iterative slope physics in the future.
     
  39. Zimbres

    Zimbres

    Joined:
    Nov 17, 2014
    Posts:
    180
    any news on this degrounding/penetration issue with non-convex meshes? (I have not run into this bug, but would like to know more about it).
     
  40. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    Has anyone had success implementing a physics-based Grappling Hook with this controller? Thanks.
     
    julekkluczak and V4LK like this.
  41. Hukha

    Hukha

    Joined:
    Aug 12, 2013
    Posts:
    61
    Hello!
    I love this Controller but I'm having some problems.
    My goal is to have the character attached to ""platforms"" (With bones, animations etc) and move relative to this but AFAIK the use for moving "platforms" is very limited. There is some possibility to make it work on top of some model with animations?

    RPV: Basically if there is some way to move relative to an object like a parent-child relation
    i.e You want to climb a ladder in an object that is moving
    Thanks!
     
    Last edited: Apr 29, 2022
    alexanderFabula likes this.
  42. emalmud

    emalmud

    Joined:
    Mar 5, 2014
    Posts:
    7
    Hello. I'm looking to mimic some physics on slopes. I turned the max slope down to 0 and that does enable the character to slide down the slope. But I guess I really want the character to be able to overcome a slope if moving fast enough. Is there an easy way to implement this?

    Also does attaching a physics material really do anything? Other than add it to the collider.

    Ultimately if I'm on the slope and sliding off it everything works fine. But because the slope angle is above the maxslope I'm not locked off.
    I know I can write my own functions for this, but more checking if I'm missing something simple because there are so many options.
     
  43. Sarudan

    Sarudan

    Joined:
    May 21, 2011
    Posts:
    65
    We switched over to FishNet a few months ago from Mirror, and we're using PUN with a dedicated server for another game, and I can assure you that it's worth the switch, especially if you have a master server / lobby solution in mind or are planning to use Playfab or Gamelift etc. I'm writing a custom Master Server / Lobby using Fishnet for total flexibility, and it handles it well since we can run two NetworkManager objects in the same scene - one for the Lobby side of things, and another for communicating with game servers to request new game server instances to be spun up on demand and load balanced.
     
    Vincent454 and aidangig56 like this.
  44. Sarudan

    Sarudan

    Joined:
    May 21, 2011
    Posts:
    65
    Hey guys, has anyone managed to get KCC working nicely with platforms in a networked game? We're using client authoritative movement in our game for responsiveness, and currently I disable the character controller and kinematic motor etc. for other players, which relies on the NetworkTransform syncing to keep them in place. Clearly this isn't ideal as you end up with the other players visually sliding around more on the platforms, which is even more exaggerated when running at higher network latencies.

    Has anyone approached this issue yet and found an elegant solution?
     
  45. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    KCC should work with Client Auth, however it is not friendly for Server Auth. I simply shelved this asset.
     
  46. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Are you saying it is bad for Multiplayer solutions for any server authentication?
     
  47. aidangig56

    aidangig56

    Joined:
    Aug 10, 2012
    Posts:
    105
    Also does not help that the developer offers little support here....
     
  48. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    No, it *can* work, with re-working of how the KCC controller does the movement / rotation
    Exactly,
    If it was made more friendly and easier to use for Serv auth and more support... it would have been a good asset

    I hear ECM 2 dev is now close to full support for Serv Auth.
     
    aidangig56 likes this.
  49. JJGutib_Cody

    JJGutib_Cody

    Joined:
    Jun 24, 2021
    Posts:
    2
    Good day everyone, not sure if someone's tried or needed this yet but does anyone know how to lock the controller's position on a specific axis? Say, if I'm making a 2.5D platformer, and I'd like the controller position's Z axis to always be zero. I'm only using the Example Character Controller for now, by the way.
     
  50. JJGutib_Cody

    JJGutib_Cody

    Joined:
    Jun 24, 2021
    Posts:
    2
    For anyone interested, I've made a very basic solution in the mean time, I've added this to the end of UpdateVelocity:
    Code (CSharp):
    1. Vector3 ZeroZTargetPosition = transform.position;
    2. ZeroZTargetPosition.z = 0;
    3. currentVelocity += Motor.GetVelocityForMovePosition(transform.position, ZeroZTargetPosition, deltaTime);
    But I'm not sure if this is a proper solution or if there's a better way to do it.