Search Unity

[Released] Kinematic Character Controller

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

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,064
    Oh my. I figured it out, but I'm not sure if there's anything I can do to fix this. Take this situation where I'm standing at the edge of a large rotating platform for example:



    With interpolation off and a large timestep (to help visualize better), here's what it looks like from a top down view:
    https://i.gyazo.com/8d6f0ad2ce41d8cc817f13b0e57f0225.mp4

    And here's what it looks like with interpolation on. Again, with extremely high timestep to help visualize:
    https://i.gyazo.com/9863736af27e4310a9ad603bd93cb1bd.mp4

    Because of the way interpolation works, the interpolated character is always moving in a straight line to the point where it would be on the next fixed update. So it's not following a circular motion.... and since interpolation has no way of knowing what sort of motion is going on in-between frames, I don't know how this could be implemented right now.

    I think the only solution is to turn off interpolation. You can help making things smoother by locking your framerate to 60 (Application.targetFramerate = 60) and setting your fixed timestep to 0.016666 (60 fps). That way, your physics will always update at least as often as your rendering
     
    Last edited: May 29, 2019
    TreeMSI and bonzaiferroni like this.
  2. PedroHN

    PedroHN

    Joined:
    Dec 8, 2012
    Posts:
    4
    Thanks for the reply!

    1. Yes, when commenting out "currentRotation = Quaternion.LookRotation(_lerpLookDir, Motor.CharacterUp);", rootMotion rotation is working as intended.

    2.Tried changing the code that way, but the behavior remains the same.
     
  3. bonzaiferroni

    bonzaiferroni

    Joined:
    May 26, 2016
    Posts:
    30
    Thank you for tracking down the issue. How silly would it be to have the motors/controllers update in both Update and FixedUpdate? Since we are using KinematicCharacterSystem as our source of deltaTime, would that work? I realize it would be doing essentially twice the work, but I'm wondering if that would be less impact than changing the physics timestep for all the objects in the scene, potentially many more than just those controlled by KCC.
     
  4. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,064
    Making the KCSystem update on Update instead of FixedUpdate can work for basic character movement (against static objects), but it unfortunately won't be a good idea for moving platforms. Those work by knowing exactly what their pose will be on the next frame, and you need a fixed deltaTime for that.

    By updating every frame, you'd start drifting and maybe even jittering on moving platforms
     
    bonzaiferroni likes this.
  5. bonzaiferroni

    bonzaiferroni

    Joined:
    May 26, 2016
    Posts:
    30
    Thank you for following up on this. If you have any more ideas please let me know, I'll check this thread regularly.
     
    PhilSA likes this.
  6. bonzaiferroni

    bonzaiferroni

    Joined:
    May 26, 2016
    Posts:
    30
    I found an issue with using KCC on a prefab, although it only happens in the editor. PhysicsMover.OnValidate() calls
    ValidateData() which assigns required values to the Rigidbody. When viewing the prefab with the attached PhysicsMover component in the inspector, it enters an infinite loop where it seems to reload the prefab and call ValidateData() perpetually.


    Not sure if this is really a bug with KCC or Unity. Unity version is 2019.1.4f1.
     
    f0ff886f likes this.
  7. Streamfall

    Streamfall

    Joined:
    Aug 8, 2011
    Posts:
    30
    Hello @PhilSA, thanks again, this is a fantastic product.
    Two questions.

    1) I am working on a climbing mechanic, similar to Breath of The Wild. I am modifying the standard character controller for KKC. In BOTW, the character climbs around a tree regardless of the camera's position. In that case, the character simply climbs clockwise or counterclockwise when setting the input left or right. This is not the case with KKC. I am testing the movement along a cone, and with the simply resting pointed at the character, said character moves in a parabola shape along the cone.

    Background info:
    I have set the Max Stable Slope Angle set to be the highest, at 89, and the Orientation Method to Towards Movement. I have a new CharacterState called Climbing, which is changed based on the angle of the colliding mesh's quad normal ( instead of the Motor.GroundingStatus.GroundNormal). Moving up and down, this looks fine, I'm rotating the root mesh towards that normal so the character is sort of parallel to the cliffside. This looks good enough.

    This code from the CharacterController is within UpdateVelocity. I've tried several things, including using the input unmodified by the camera's plane. Any thoughts?

    Code (CSharp):
    1.  // Calculate target velocity
    2.                         Vector3 inputRight = Vector3.Cross(_moveInputVector, Motor.CharacterUp);
    3.  
    4.                         Vector3 reorientedInput = Vector3.Cross(effectiveGroundNormal, inputRight).normalized * _moveInputVector.magnitude;
    5.  
    6.                         targetMovementVelocity = reorientedInput * (MaxStableMoveSpeed * climbingMultipler);
    2) I'd like to work on movement sliding. If anyone has played Journey or BOTW, it feels really natural to slide down slopes when the mesh normal and velocity are right. I've looked around in the forum and have not seen this talked about. Any ideas where I might get started with this, while I am on the topic of UpdateVelocity?

    Thanks!
     
    Last edited: Jun 7, 2019
  8. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    Hello, first off thank you for the cool character controller.

    I've got some questions regarding do's and don'ts. I'm trying to replace the standard Unity Character Controller (the one from like 5 years ago, that came in Standard Assets), for the sole reason of having animated box colliders smoothly move the player. For example, you're standing infront of a drawer of a desk, you open the drawer, and I can rely on KCC + the animation on the drawer to just displace the user backwards. I tested this on your test scene and it seems to work OK (I just animated a cube with a box collider back and forth and walked into it).

    We don't have jumping in our game or anything like that, just walking, running and crouching.

    Now, my questions:
    1) is it OK to animate a box collider like that (via Animation/Timeline) and not have to add a PhysicsMover component? as I said it worked OK but I want to be sure
    2) we have moments where we parent our Player (which contains the character controller) to another GameObject because we sometimes teleport the entire room around in the world where the player is standing (without the player seeing any effect), in the documentation it said to not do this... what is the right way to achieve our functionality then? do I just always teleport the room and SetPosition with KCC the local position of the Player afterwards? Will this be seamless from frame to frame?
    3) We animate moving platforms sometimes (with an actual animation/timeline). I tried animating a platform the player is standing on, but the behaviour isn't correct (they do jitter as the platform moves up, and as it reaches the peak of its motion the player is flung up a little :D). I'm assuming this is because I'm not using PhysicsMover, but how should I use physics mover paired with artists' animations? Also, we use box collider components for everything, not rigid bodies...

    Apologies if these are answered before in the forum, I tried reading every page but didn't see these same topics.

    Thanks!
    Matt
     
  9. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    There's one other question that was discussed in the thread but I am not so clear on the solution: I have a lot of logic around OnTriggerEnter/Exit that would be too much to refactor to use other methods.

    I'm trying to understand how to trigger these scripts with KCC, there's no component on it that seems to fire the collision event. I know you said it can be a frame late, but that doesn't matter, we're using volumes for different effects and notifications when the player has entered a given area, for example (and when they leave it).

    Putting any collider or rigidbody on the KCC Character or any subobject doesn't leave happy results :D It has a capsule collider, why isn't that enough?

    *edit*
    Apologies for the spam, I think the more I experiment the more questions I have and the further away from my goals I get :)

    So, I have to retract my earlier statement that just animating a Box Collider will push my character around smoothly. It pushes, but it isn't perfectly smooth. Its smoother than using Unity's CCT, but its not ideal.

    Now, I found a post where you describe to create an object that has an IMoverController implemented, and in there all I do is set goalPosition and goalRotation to the animated object. So I did that, its super simple, just copies the animated transform's position and rotation to the goal.

    I've set it up so that the box collider as the exact same world position as the original collider I'd use, and tried with it as a child object of the animated object and not as a child, I still get that small jitter.

    Is there any ideas why that would happen? To be clear, there is no difference in the behaviour of jitter between using the PhysicsMover+IMoverController and just simply animating the box collider.

    Important to note that it only happens on the XZ plane, so when an object is pushing me along the surface I'm standing. If I stand on another object and animate it up and down, KCC follows it perfectly smoothly.

    Last update: I think this might actually be the animation itself not being interpolated perfectly smoothly... it's just too odd that in every other case (ie. the test scene you provide with the two blue sliding platforms) the movement is perfectly smooth.

    Thanks again,
    Matt
     
    Last edited: Jun 5, 2019
  10. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    I'll write a reply again so as not to lose information in my spaghetti train of thought.

    I'll answer some of my own questions for anyone asking:

    1) To get the Player to trigger OnTriggerEnter in other scripts: I added a child GameObject, added a Box Collider + Kinematic Rigid Body to the child, and set its layer to PlayerCollider. I turned off the physics collisions between my Player's layer (which has to be separate from the layer that the box collider triggers are on!) and PlayerCollider. This allowed the collider to be attached, and it didn't cause things to explode with self-collision, and better yet all my existing scripts worked. So you need three layers minimum: Default for all normal objects / box trigger colliders, etc. PlayerCollider for the rigidbody+box collider child of your player with KCC, and PlayerController for the GO with the KCC motor.

    2) I can confirm that reparenting (and making sure lossyScale is always 1,1,1) and immediately calling SetPositionAndRotation on the Motor component after I move the parent works OK. There is no visual disruption and no extra calculation to be done, simply immediately calling KCCMotor.SetPositionAndRotation(KCCMotor.transform.position, KCCMotor.transform.rotation) is enough.

    3) I have been experimenting with and without PhysicsMover and animated Box Colliders, it seems that only when the moving object is indeed a platform for the player is it required. Otherwise, I haven't observed better movement by adding a PhysicsMover + MoverController and mimicking existing colliders. This is still an open question, as I never was able to achieve such perfect fluid movement as in the example scene with the sliding blue platforms pushing the player around (don't jump on them, just stand infront of them, the two long ones that slide back and forth really fast).

    It looks like its enough for me to transition over my actual Controller tomorrow :)
     
    Streamfall likes this.
  11. Rademanc

    Rademanc

    Joined:
    Feb 2, 2013
    Posts:
    9
    Hi there.
    I am trying to make a conveyor belt. So what I currently do is have the conveyor register itself with the character controller as a external velocity modifier, and then I just pass the character velocity as an argument to each modifier.
    This works fine. The problem is I have to use triggers to add and remove these modifiers. So when the character reaches the end of the conveyor belt he shoots off in the direction of the conveyor because he's no longer in contact with the ground, but still has the conveyor modifier attached.
    As you can imagine I want to avoid having to fiddle with trigger zones to get the behavour just right.
    Is there a better way to do this?
    Great asset by the way.
    Cheers.

    Ok so I pass the grounding status of the character to the modifiers and that has solved that particular problem, it just feels that there is a better way. :)
     
    Last edited: Jun 8, 2019
  12. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    Hi, this may be a weird question, but has anyone experienced almost constant editor crashing due to a prefab containing KCC components (specifically KinematicCharacterMotor)? I haven't narrowed it down 100% but after migrating to KCC I've got 3 machines crashing on every other AssetDatabase.SaveAssets(), unfortunately I can't see exactly where but its always inside SavePrefabAsset, and now I'm starting to worry it could be due to the KCC migration (unfortunately it touched so much code and scenes I can't step back and forth between the two easily).
     
  13. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    I think this is related to my crash question above. It was on 2018.3.11f1, 2018.4.1f1, and 2018.4.2f1. I am going to comment out the OnValidate() code in KinematicCharacterMotor (that is the component on my Prefab that comes from KCC).

    I can 100% confirm the crashes are caused by my PlayerFPC (which has the KinematicCharacterMotor component), perhaps this is the reason, I'll edit this post if I don't get any crashes in the next few hours (I can get a crash every 2-3 minutes...).

    UPDATE: I can confirm my crashes disappeared (and the Editor log file no longer has many repeating entries where it is updating my prefab and serializing it).
     
    Last edited: Jun 10, 2019
    judah4 and bonzaiferroni like this.
  14. bonzaiferroni

    bonzaiferroni

    Joined:
    May 26, 2016
    Posts:
    30
    Yeah I saw KinematicCharacterMotor doing the same thing for the same reason, although I never got a crash. I'm not sure there have been changes to when OnValidate gets triggered that might have caused this, but it goes into an unending loop in that context I mentioned above. Since this happens across several frames it isn't enough to make the program unresponsive, I only realized it was happening because the cursor/icon was changing. But if there is other code that gets triggered by OnValidate on that prefab it might have more serious consequences.

    I haven't experimented but I suspect the issue is with assigning values to properties that are visible in the inspector, which might trigger another OnValidate call on the next frame. I wonder if introducing some if-statements to check the value first before assigning it might produce the desired behavior without the infinite loop.
     
  15. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    Alright I don't understand PhysicsMovers and the magic combination between getting jittery output and getting smooth output.

    Here is a blue platform setup as two sibling GameObjects: one has the blue box and a DOTween script on it that just loops a MoveY tween up and down, and the other has a PhysicsMover, Box Collider, Rigid Body (kinematic) and a script containing:

    Code (csharp):
    1. public class AnimationMover : MonoBehaviour, IMoverController
    2. {
    3.     public Transform ReferenceObject;
    4.     // Start is called before the first frame update
    5.     void Start()
    6.     {
    7.         var mover = GetComponent<PhysicsMover>();
    8.         if (mover)
    9.         {
    10.             mover.MoverController = this;
    11.         }
    12.     }
    13.  
    14.     public void UpdateMovement(out Vector3 goalPosition, out Quaternion goalRotation, float deltaTime)
    15.     {
    16.         goalPosition = ReferenceObject.position;
    17.         goalRotation = ReferenceObject.rotation;
    18.     }
    19. }
    Here's how it looks when I stand on it:


    Notice the jitter in the movement of the platform, the player starts to float, and penetrates on the bottom. The platform looks smooth if I'm not standing on it.

    I want to get this behaviour on an animated or tweened platform:


    Anyone know how to fix this difference?
     
    4myGod and Vincent13122 like this.
  16. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    85
    can anyone tell me please how you make the kinematic character move without going into other colliders (i dont own this asset,I'm just learning)
     
  17. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    134
    Hey! KCC looks great when trying it out but I'd like to start on some customisation and I got stuck pretty fast :/ User Guide was pretty clear so I happily moved to the walkthrough. It started rather simple but then when I was hoping for the first basic movement code with (even basic) explanation but it just says "take a look at function X" which starts with:
    Code (csharp):
    1.           // Reorient source velocity on current ground slope (this is because we don't want our smoothing to cause any velocity losses in slope changes)
    2.                 currentVelocity = Motor.GetDirectionTangentToSurface(currentVelocity, Motor.GroundingStatus.GroundNormal) * currentVelocity.magnitude;
    3.  
    I mean I guess the comment explains what the code below is doing but none of smoothing, velocity losses or slope changes were mentioned before and this is the very first line of 1st lesson and basic velocity calculation step.

    Then I realised that the rest of the walkthrough is actually the same: 1. open scene 2. look at the code. Now please don't get me wrong, no hand holding is needed. No code or quaternions scare me but this is a lot to process when starting and while I understand that KCC is meant to be advanced tool, it would be super helpful to get more guidance on the process.
     
  18. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    157
    Replying to provide information about this in case anyone has troubles like I did:

    The secret to get a smooth visual result is that the object which has the Physics Mover, the Collider and Kinematic Rigid Body, _must also_ have the visual representation. Either directly on the object, or as a child.

    My issues arose because I was trying to synchronize the visual representation with a different gameobject that had the collider and mover.

    So make sure your "Physics Mover" has everything! Then its enough to just set the transform position + rotation from your IMoverController based on the transform of whichever object you want to track.

     
  19. Husain136

    Husain136

    Joined:
    Sep 13, 2015
    Posts:
    3
    If my character has gone prone, can i do that i can rotate the collider so that it is sleeping horizontally and still move forward? I just want the capsule to be horizontal so that it matches my characters pose (proning), and the controller still be able to move forward?
     
  20. domx

    domx

    Joined:
    Jul 23, 2013
    Posts:
    6
    Hi, thanks for the great asset! I was wondering if there is any chance you still have 2017.4x compatible version of the controller available (or could share it), since we cannot upgrade to 2018 at this time. Cheers!
     
  21. MachineMalfunction

    MachineMalfunction

    Joined:
    Oct 12, 2014
    Posts:
    1
    On this note, I'd like two characters that move directly into each other to just stop each other in their tracks, rather than jitter like crazy:



    When only one KCM has velocity, it seems to be blocked by the other just fine.

    Any pointers?
     
  22. Win3xploder

    Win3xploder

    Joined:
    Dec 5, 2014
    Posts:
    17
    Hi, I'm having an issue with my root motion character. I'm trying to walk up stairs but my character slows down a lot when trying to walk up the steps. I'm using the root motion sample code for movement.

    Edit: The steps are individual objects. When using a single merged object the issue does not occur. However, I find this rather limiting from an environent art perspective. What can I do to prevent this?
     
    Last edited: Jun 27, 2019
  23. Ragoo

    Ragoo

    Joined:
    Feb 15, 2014
    Posts:
    64
    Hi PhilSA,

    I'm trying to make the controller behave as though the base sphere is 0.5 or 1 in radius in order to traverse obstacles smoothly, but I want the actual collider radius to be only 0.2. Is there any way in which I can achieve this?
     
  24. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    38
    With the Kinematic Character Controller, are there any feedback properties I can fetch?
    I need the movement velocity and direction returned after calculations, normalized from any platform movement and collisions
    Current ground slope, etc

    Say if I feed the motor a direction vector and it hits a wall,l I need to fetch the resulting vector so I know what speed to play back the animation if any

    Another question regarding the Physics Mover, if it's on the parent object, is that enough? or would it have to be on child objects too? There maybe a case in my application where the child objects far exceed the bounds of the parent for a platform.

    Lastly, is the Physics Mover optimised or should I look at upgrading it to a shared script?
    say if I need 10k of them in a scene.
     
    Last edited: Jul 9, 2019
  25. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    38
    You could use physical layers and have two seperate physics, one for your character's motor and the other for misc objects in your scene
    so the motor can navigate smoothly and push items out of the way based on mesh collision, or a tiny sphere.
    Layers can be amazing
     
  26. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    38
    before I forget, i've had trouble getting multiple Character controllers and PhysicsMovers into my scene, they always create the following error

    NullReferenceException: Object reference not set to an instance of an object
    KinematicCharacterController.PhysicsMover.VelocityUpdate (System.Single deltaTime) (at Assets/KinematicCharacterController/Core/PhysicsMover.cs:220)
    KinematicCharacterController.KinematicCharacterSystem.Simulate (System.Single deltaTime, System.Collections.Generic.List`1[T] motors, System.Int32 characterMotorsCount, System.Collections.Generic.List`1[T] movers, System.Int32 physicsMoversCount) (at Assets/KinematicCharacterController/Core/KinematicCharacterSystem.cs:201)
    KinematicCharacterController.KinematicCharacterSystem.FixedUpdate () (at Assets/KinematicCharacterController/Core/KinematicCharacterSystem.cs:146)

    I have the Kinematic Character System on my Game manager object, so it should be fine
     
  27. Ragoo

    Ragoo

    Joined:
    Feb 15, 2014
    Posts:
    64
    Thanks for the suggestion @digimbyte , but I don't want the controller's increased radius to act with the scene objects as such, solely the ability for the controller to climb greater objects gradually (i.e. not via the jarring step functionality).
     
  28. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    38
    That's what layer masking is for.
     
  29. srogers144

    srogers144

    Joined:
    Sep 1, 2016
    Posts:
    6
    Hey all!

    Recently I got this asset, which is fantastically useful and very well made. I am having an issue though, and i likely stems from me working very late a night on it, but I wanted to know if anyone one here has experience adjusting the camera view for an over the shoulder style view?

    I run into 2 issues, 1 being that most methods I have tried the camera just snaps back to the original placement. Second, if I adjust the camera target, than the player seems to move at a bit of strange angle.

    Any input on the best way to achieve this? I've been able to modify it for most of my uses I'm just getting very hung up on this for some reason.

    Thanks on advance, and thanks for such a powerful controller!
     
  30. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    293
    Hi,

    When my character animates its lagging behind while running, I read another response here and you suggested putting the fixed timestamp to 0.005 and when I did that it fixed the issue but with 0.02 it doesnt work. Im also using Animancer Pro instead of the animator, any ideas?
     
  31. Kmeier

    Kmeier

    Joined:
    Feb 9, 2016
    Posts:
    10
    Hey @PhilSA , this controller has been a fantastic asset for me!

    I was wondering if you had any insight as to how I could go about wall detection. I'll explain the context:

    My game allows the player to wall run. As I have it programmed now, while airborne, OnMovementHit triggers the logic to decide if a wallrun is possible, then activates that state if it is. Because of my reliance on OnMovementHit to trigger the wallrun logic while airborne, it means that a player who walks up to a wall while grounded (now touching/colliding with it) and then jumps never gets that wallrun detection logic triggered. This has been super confusing for my playtesters. Is there any way I can continuously check collisions with surfaces?

    My current alternative is to just roll my own raycast system to detect the walls within "wallrun" range, but I wanted to see if you had a more elegant solution that I may have missed using the current API.

    Thanks!
     
  32. MasterColonico

    MasterColonico

    Joined:
    Jul 23, 2016
    Posts:
    5
    Hi @PhilSA, do you have any plans to create a version of KCC that supports ECS, Jobs, and Burst? I quickly tried to convert to the new Mathematics library myself but ended up with some bizarre "Invalid AABB" errors, so I reverted for now.
     
  33. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    410
    Once in a while, I will get this error when I press Editor's play mode.
    It happens at totally random. Most of the time, it didn't.
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. KinematicCharacterController.KinematicCharacterMotor.UpdatePhase1 (System.Single deltaTime) (at Assets/KinematicCharacterController/Core/KinematicCharacterMotor.cs:766)
    3. KinematicCharacterController.KinematicCharacterSystem.Simulate (System.Single deltaTime, System.Collections.Generic.List`1[T] motors, System.Int32 characterMotorsCount, System.Collections.Generic.List`1[T] movers, System.Int32 physicsMoversCount) (at Assets/KinematicCharacterController/Core/KinematicCharacterSystem.cs:207)
    4. KinematicCharacterController.KinematicCharacterSystem.FixedUpdate () (at Assets/KinematicCharacterController/Core/KinematicCharacterSystem.cs:146)
    I am worried it might happen at runtime, is there anything I did wrong?
     
  34. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    404
    I think this asset looks amazing.

    Is there any docs or tutorials on how to properly replace the cylinder with a character with basic animations? :)
     
  35. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    39
    Hey @PhilSA,

    I believe the ladder walkthrough now no longer works with your latest version. Just wanted to let you know. I can work around it as of now since I have a better understanding of how the motor works, but others may be having issues who are just now starting to use the tool. The only way for me to learn was via your walkthroughs.

    Cheers,
    TrollHouseGames
     
  36. Ooi

    Ooi

    Joined:
    Nov 22, 2015
    Posts:
    11
    Vincent13122 likes this.
  37. ve110cet

    ve110cet

    Joined:
    Dec 11, 2017
    Posts:
    6
    I believe I fixed it by changing "motor.SetMovementCollisionsSolvingActivation(false);" in OnStateEnter() to "motor.SetGroundSolvingActivation(false);"
     
    TiToMoskito and Bubsavvy like this.
  38. Berserker44

    Berserker44

    Joined:
    Sep 1, 2013
    Posts:
    22
    This is great, awesome job porting over the thirdpersoncontroller. I am trying to do the same but I am having some difficulties. Would you mind sharing how/what you did to get it to work correctly?
     
    PenleyChan likes this.
  39. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    34
    pls check here
     
  40. TomatoLamp

    TomatoLamp

    Joined:
    Feb 8, 2013
    Posts:
    2
    Maybe I'm overlooking something, but when you add a Rigidbody object to the KCC's "IgnoredColliders" list - it's still possible to move the ignored object occasionally and seemingly only from certain angles.

    Thing I tried:
    • I have this issue in my own project and was able to replicate it in the "playground" scene by using the blue rigidbody cubes (easier to test if you lower their mass).
    • I can also confirm that any non-rigidbody mesh added to the list is properly ignored
    • I tried configuring the KCC's rigidbody options in various ways to no effect
     
  41. sateyr

    sateyr

    Joined:
    Mar 6, 2013
    Posts:
    4
    Hi,
    Any new with moving sideways in the air??
     
  42. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    34
    Does some has also issues with the ladder walkthrough?
    When im infront a ladder and press E, than it anchors to the ladder but after second it deanchors.
     
  43. Bubsavvy

    Bubsavvy

    Joined:
    Sep 18, 2017
    Posts:
    39
    TiToMoskito likes this.
  44. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    277
    Hello!
    I'm experimenting with KCC, and there is trouble I need help with.
    My character is on a boat, boat moves, the character moves with it, all ok. But when boat rotates, the camera is not rotating with it (which is expected) but I need it to. I did read a post where you suggest to rotate the camera by an angle of physics mover rotation so the question is:
    How do I get physics mover delta rotation without hacks (I need to swap boats, leave and enter a boat, so just grabbing a reference is not a proper solution) Can I pull the data of a physics mover currently affecting my character from my character controller somehow?
     
  45. OldLegWig

    OldLegWig

    Joined:
    Mar 18, 2018
    Posts:
    77
    @shamsfk I think you are looking for the AttachedRigidbody in KinematicCharacterMotor.cs. You can calculate your rotation delta from that rigidbody's rotation. Of course you'll want to null check that rigidbody first.
     
    shamsfk likes this.
  46. Shrandon

    Shrandon

    Joined:
    Nov 13, 2012
    Posts:
    3
    Hey, potentially found a bug with manual simulation with interpolation turned off.
    Sometimes after landing there is a large speed boost upon landing when stable ground speed is uncapped (which it needs to be in my game):
    https://gyazo.com/72801a09f275a0da874545a2b40cafd0

    This happens when using a manual simulation (Simulate called in Update), interpolation disabled, and with an uncapped ground movement speed. It seems to occur on any surface, including flat ground.
    I believe to have narrowed it down to an issue somewhere in InternalCharacterMove via logging, but could be wrong.

    You can reproduce this issue in the example project with the following changes:

    1. Set:
    Code (CSharp):
    1. KinematicCharacterSystem.AutoSimulation = false;
    2. KinematicCharacterSystem.Interpolate = false;

    2. Add somewhere unique (I added to ExampleCharacterController.cs and disabled the AI characters walking around)
    Code (CSharp):
    1.  void Update()
    2. {
    3.     KinematicCharacterSystem.Simulate(Time.deltaTime,
    4.                 KinematicCharacterSystem.CharacterMotors,
    5.                 KinematicCharacterSystem.CharacterMotors.Count,
    6.                 KinematicCharacterSystem.PhysicsMovers,
    7.                 KinematicCharacterSystem.PhysicsMovers.Count);
    8. }

    3. Change the line below "Smooth movement velocity" in ExampleCharacterController.cs from:
    Code (CSharp):
    1. currentVelocity = Vector3.Lerp(currentVelocity, targetMovementVelocity, 1f - Mathf.Exp(-StableMovementSharpness * deltaTime));
    to
    Code (CSharp):
    1. currentVelocity += reorientedInput * MaxStableMoveSpeed * deltaTime;

    4. Add some way of displaying your speed (not including the y component).

    5. Jump and observe the issue sometimes occurring when landing (seems to increase in frequency at higher frame rates).
     
  47. LezTusi

    LezTusi

    Joined:
    Nov 15, 2014
    Posts:
    28
    how to use CharacterSweep() properly?
    I'm testing this code to check if there's a wall near the player since I can't find to "inflate" the hit stability report to detect hits. the hit normal and points are important in my case so overlap tests won't work.

    Code (CSharp):
    1.         RaycastHit[] WallCheckHits;
    2.         RaycastHit ClosestWallCheckHit;
    3.         public LayerMask WallCheckTargetLayer;
    4.         void OnDrawGizmos()
    5.         {
    6.             float radius = .125f;
    7.             Vector3 pos1 = Motor.InterpolatedPosition + Motor.CharacterTransformToCapsuleTopHemi;
    8.             Vector3 pos2 = Motor.InterpolatedPosition + Motor.CharacterTransformToCapsuleBottomHemi;
    9.             Vector3 pos3 = Motor.InterpolatedPosition + Motor.CharacterTransformToCapsuleCenter;
    10.            
    11.             bool isHit = Motor.CharacterSweep(pos3, Motor.InterpolatedRotation, transform.forward, 2, out ClosestWallCheckHit, WallCheckHits, WallCheckTargetLayer, QueryTriggerInteraction.UseGlobal, radius) > 0;
    12.  
    13.             Gizmos.color = isHit ? Color.red : Color.green;
    14.             Gizmos.DrawWireSphere(pos3 + transform.forward * ClosestWallCheckHit.distance, Motor.Capsule.radius+radius);
    15.             Gizmos.DrawWireSphere(pos1 + transform.forward * ClosestWallCheckHit.distance, Motor.Capsule.radius+radius);
    16.             Gizmos.DrawWireSphere(pos2 + transform.forward * ClosestWallCheckHit.distance, Motor.Capsule.radius+radius);
    17.         }
     
  48. MikeFish

    MikeFish

    Joined:
    Oct 24, 2015
    Posts:
    12
    quick question, having updated an old project and the following seems not to be working in the current stable unity release, or is it just me:

    Rigidbody Interaction Type: Kinematic

    this used to work very fine for my non realistic toony platformer, unfortunatel it seems to have no effect anymore in 2019.2.3f1, the controller just moves through all rigidbodies in the scene without affecting them at all.
    The "Simulated" setting works as always, but is not what I need in this project.

    Anyone else experiencing this?
    Is there a solution?
    I doubt the error is on my side, as i am having same results in a fresh project using the walkthrough scenes as base.

    cheerio,
    Michael
     
  49. MikeFish

    MikeFish

    Joined:
    Oct 24, 2015
    Posts:
    12
    Quick follow up question:

    Does anybody know if this asset is still supported by the dev?
    Seeing, there hasn't been replies by him since 2nd of june, makes me wonder.

    I hope it is.
     
  50. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    309
    "PhilSA was last seen:Yesterday at 10:00 PM". I think he is just busy on something else, try to email him. I emailed him for support before, he is responsive and helpful.
     
    MikeFish likes this.