Search Unity

[Released] Kinematic Character Controller

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

  1. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Hey I'm having an issue where my character can push other rigidbodies out of the way, regardless of the mass of the rigidbody being pushed. Trying to make it where the character can't push heavy stone blocks by walking into them/etc. Am I missing some setting somewhere, or is this currently not a feature?
     
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    You should be able to make it react physically to rigidbodies by setting "RigidbodyInteractionType" to "Simulated Dynamic" on the KinematicCharacterMotor. Tweak the "SimulatedMass" for the push force. I've found 0.2 works well in general
     
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    In case you guys missed the release notes for v2.1 and v2.1.1, here they are
    Release notes will always be up to date in the original forum post from now on.

    _______________________

    I'd also like to take this opportunity to introduce....
    The (WIP) networking example!

    For now I will be leaving this on github because several features are missing (see github page), and it is very rough and unoptimized in some places. Once it becomes more polished, documented and full-featured, I will release it with the actual package on the store. Most of the information you need to know is on the github page, but don't hesitate if you have questions.

    For this to work correctly, you'll need KCC 2.1.2 which isn't on the store yet, but it should be here within a few days.

    To my knowledge, everything is working fine right now except for the missing things mentionned in the roadmap on the github page. But do let me know if you see bugs

    I will not be working directly in this repository, so it's normal if you don't see many commits being made. Instead, I will simply update the repo with new versions when notable additions have been made
     
    Last edited: Mar 21, 2018
    Ellernate and Guacamolay like this.
  4. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    As it is right now, your cameraOrientedMoveInput will be pointing downwards more and more depending on the view angle. You should try something like this:
    cameraOrientedMoveInput = Vector3.ProjectOnPlane(Quaternion.LookRotation(OrbitCamera.Transform.forward, OrbitCamera.Transform.up), Motor.CharacterUp).normalized * _moveInputVector;
     
    Last edited: Mar 21, 2018
  5. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Thanks! I'll give that a shot and see how it goes.
     
  6. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Actually, let me take that back. More changes are needed in KCM for this to work, and so it would probably be better to just wait for 2.1.2. It is already submitted, so it shouldn't take more than a few days
     
  7. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    97
    Nice! I'm super excited to check this out!
     
  8. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    So this controller is absolutely superb, but there is one thing I can't figure out. The AI pathing example is fine, but the main problem is that there's no way to handle off mesh links, which are kind important for doing stuff like jumping over gaps, jumping upwards or falling off ledges. I've been trying to mix an AI controller and nav mesh agents, but so far the agent seems to just be stuck against the edge of the nav mesh when trying to follow the player across a gap. An example of how to make an AI that uses links would be absolutely great.
     
  9. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    For the time being, I don't know the navmesh API well enough to give you a clear answer of how this would be done. But I know they're supposed to make changes to the API in Unity 2018.X to make it more Low-Level and more usable for things that aren't the built-in NavMeshAgent (see last comment in this thread). So I'll keep that in mind and look into expanding the example once new features arrive

    However I'm sure there are ways to accomplish this right now. I think it would go something like this:
    1. Find out which navmesh is at the target destination
    2. Find out which navMeshLink leads to there
    3. CalculatePath to that navMeshLink
    4. Execute your game-specific code for the navmesh transition you want to happen (jump, fall down, climb ladder, etc.....)
    5. CalculatePath to the final target
     
    Last edited: Mar 23, 2018
  10. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    KCC v2.1.2 is now live on the store.

    It includes a fix for an issue with slope launching determinism as reported by @Guacamolay ,
    as well as some tweaks to allow compatibility with the networking example preview. The details are on the github page
     
    Guacamolay likes this.
  11. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    The problem is, NavMesh doesn't let you do that. Hell, it doesn't store any data related to nav mesh links, only the nav mesh agent does. So as far as I can tell, that's basically impossible, unless I'm missing something.
     
  12. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    It's possible that the solution would be to make a custom NavMeshLink script, along with some kind of NavmeshesManager that knows what links link each navmesh

    Or actually just the manager would suffice, and it can reference regular NavMeshLinks
     
    Last edited: Mar 23, 2018
  13. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    Well, I'm not really sure how I'd make a usable manager, really, or make it usable with pathfinding, so that's still an issue xD Especially in cases where the off mesh links are linking to the same mesh.

    Again, the nav mesh data and the link data is completely separate and link data isn't included in nav mesh paths, so it'd basically require a rather roundabout method of pathing. Bleh.

    Edit: So the calculated path knows there's a path across the off mesh link, but it only works properly if you're not constantly recalculating the path, otherwise the AI gets stuck on the start of the link, but there's simply no way to know when not recalculating is necessary, so that's back to square one.
     
    Last edited: Mar 23, 2018
  14. Candescence

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    Okay, so I've managed to figure out how to use a dummy agent to calculate paths and be able to access the next off mesh link in the path, along with a child object so the AI knows when they're close to a link start/end.

    That being said, the actual behaviour of the AI is strange, as it takes some very bizarre pathing decisions immediately after performing a link traversal a good deal of the time, and Unity throws an error at me when I try to access the link's area, nevermind the distance method of detection isn't terribly consistent for some reason. But it's a step in the right direction.

    Code (CSharp):
    1.  
    2. private void HandleCharacterNavigation()
    3.         {
    4.             _navAgent.SetDestination(Destination.position);
    5.             if (_navAgent.hasPath && !_traversingLink)
    6.             {
    7.                 _path = _navAgent.path;
    8.                 _navAgent.SetPath(_path);
    9.             } else
    10.             {
    11.                 //if (NavMesh.CalculatePath(Character.transform.position, Destination.position, NavMesh.AllAreas, _path))
    12.                 //{
    13.                 //    _lastValidDestination = Destination.position;
    14.                 //}
    15.                 //else
    16.                 //{
    17.                 //    NavMesh.CalculatePath(Character.transform.position, _lastValidDestination, NavMesh.AllAreas, _path);
    18.  
    19.                 //}
    20.             }
    21.  
    22.             AICharacterInputs characterInputs = new AICharacterInputs();
    23.  
    24.             for (int i = 0; i < _path.corners.Length - 1; i++)
    25.                 Debug.DrawLine(_path.corners[i], _path.corners[i + 1], Color.blue);
    26.  
    27.             //print((_navAgent.nextOffMeshLinkData.startPos - navBottom.position).magnitude);
    28.  
    29.             if ((_navAgent.nextOffMeshLinkData.startPos - navBottom.position).magnitude <= DistanceToLink && !_traversingLink)
    30.             {
    31.                 _offLinkData = _navAgent.nextOffMeshLinkData;
    32.                 _traversingLink = true;
    33.                 characterInputs.ShouldJump = true;
    34.                 print("New link!");
    35.             }
    36.  
    37.             int cornersCount = _path.GetCornersNonAlloc(_pathCorners);
    38.             if (_traversingLink)
    39.             {
    40.                 if ((_offLinkData.endPos - navBottom.position).magnitude <= DistanceToLink)
    41.                 {
    42.                     characterInputs.ShouldJump = false;
    43.                     _navAgent.CompleteOffMeshLink();
    44.                     _traversingLink = false;
    45.                 }
    46.                 else
    47.                 {
    48.  
    49.                     //if (_offLinkData.offMeshLink.area == 2)
    50.                     //{
    51.                     //    characterInputs.ShouldJump = true;
    52.                     //}
    53.                     //else
    54.                     //{
    55.                     //    characterInputs.ShouldJump = false;
    56.                     //}
    57.  
    58.                     // Build the CharacterInputs struct
    59.                     characterInputs.MoveVector = (_offLinkData.endPos - navBottom.position).normalized;
    60.                     // Apply inputs to character
    61.                     Character.SetInputs(ref characterInputs);
    62.                 }
    63.             } else
    64.             {
    65.                 if (cornersCount > 1)
    66.                 {
    67.                     // Build the CharacterInputs struct
    68.                     characterInputs.MoveVector = (_pathCorners[1] - Character.transform.position).normalized;
    69.                     // Apply inputs to character
    70.                     Character.SetInputs(ref characterInputs);
    71.                 }
    72.                 else
    73.                 {
    74.                     // Build the CharacterInputs struct
    75.                     characterInputs.MoveVector = Vector3.zero;
    76.  
    77.                     // Apply inputs to character
    78.                     Character.SetInputs(ref characterInputs);
    79.                 }
    80.             }
    81.        
    82.         }
    83.  
     
    Last edited: Jun 4, 2018
    PhilSA likes this.
  15. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    oops, yeah I meant to write that
     
  16. elKarkayu

    elKarkayu

    Joined:
    Mar 23, 2017
    Posts:
    18
    would it work with the cam following the player?
     
  17. Steel-Grin

    Steel-Grin

    Joined:
    Aug 28, 2013
    Posts:
    16
    Is it possible to get an older version of this asset? I updated without realising that you removed the class based state machine and would like to use it as a reference as I make my own. I personally dislike the enum approach.
     
  18. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Yes, the orbit camera in the demo is just an example camera written for the sake of demonstrating the controller, but it could work with any other custom camera (including cinemachine)
     
  19. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Sure, I'll send it to you via PM
     
  20. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Hello! First of all, thank you for this amazing asset, it is exactly what I needed for my project.
    I have been using it for a couple of months now and everything worked well. However, I have found a couple of bugs in the newer versions (2.0+).

    1. When walking, jumping and then letting go of the movement keys and only pressing space to jump every time the character lands, he has infinite momentum and it even adds some speed sometimes. This is not present in older versions.

    2. (Maybe related) If the characters speed is not zero and you jump and land without pressing anything, he will sometimes slide in the jump direction for a short time. This has been there since at least 1.2.2 and it is a bit annoying.

    3. Really weird one: In my project when I set the gravity to -15 or higher up until 15 he just floats in mid air. Any other value works as it should. Am I doing something wrong? This also happens in the example project but with values of -10 and 10.

    If you need more information on this I can maybe upload a video.
     
  21. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I'll have a look at these problems shortly. I did notice the landing problem a few times in my tests too
     
  22. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
    EDIT: I fixed my issue, my IDs in CharacterController where assigned minus one what they should've been.
     
    Last edited: Apr 5, 2018
  23. kindingerlek

    kindingerlek

    Joined:
    Jul 7, 2015
    Posts:
    10
    Hello @PhilSA

    I recently bought your plugin. Testing it at demo scene, this makes me love at first sight. However, I have two troubleshoot:

    First, if you make the character goes over the terrain (green) in the demoscene, on diagonal direction, sometimes, the player gets stuck. Is relative hard get this behaviour, even small mouse movements can be unstuck player from this condition. This is not a really big problem for me, but I believe this maybe can be important to you.

    Second, there is a way to move the "KinematicCharacterController" folder to a subfolder, like "Plugins" or "AssetStoreTools"? When I do that, I cannot add KinematicMotor to my character, and Unity gets frozen. This really important to me to keep the main folder organized.

    Thank you for your support, and the awesome Character Controller.:D
     
    Last edited: Apr 6, 2018
  24. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Thanks for reporting this. I'll see if I can repro it

    This is pretty weird. I tried it in 2017.3.1f1 and couldn't repro that bug. But I'll let you know if I find anything
     
  25. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Another one Ive found in the new version only is that if you move towards a wall, especially noticeable when falling down, the player will stutter and slow down.
     
  26. kindingerlek

    kindingerlek

    Joined:
    Jul 7, 2015
    Posts:
    10
    Well, I do not know what happens, but after restarting my machine, and consequently, kill all unity process on doing that, I am able to move the plugin folder to a subfolder, without any problems. Really weird. Probably was a Unity bug with the scriptableObject pipeline, once the log error was "Can't create an instance of Kinematic Motor". Sorry about that, I should tested this before. My fault.

    However, the first issue still present, even on WebGL demo. Again, this not so important to me at this point.

    Anyway, thank you again for support.
     
  27. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Is this in KCC v2.1.2? This is something I thought I fixed, but it's entirely possible that there are still ways to repro the problem
     
  28. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    Yes, it is
     
  29. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    could you send me a gif of it happening and/or steps to repro the problem?
     
  30. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    There you go: https://giphy.com/gifs/1nQaWeKt5aXNAvmjC0 It only happens if your movement direction is almost exactly towards the surface normal of the collider. If it is slightly different it does not happen, as you can see in the gif.
     
    PhilSA likes this.
  31. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    thanks, I'll check this out. This isn't the problem I thought I fixed
     
  32. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I've started a wave of bugfixing for the latest bugs reported here, and I'm having a bit of trouble repro-ing some of them. I'll need to ask for some additional info

    Here's how I'm trying to test this: https://i.gyazo.com/cadeea58e90327c96813c257a09da502.mp4
    So far I haven't seen the problem happen. Can you validate if I'm testing this correctly, and if so, provide a screenshot of ther KinematicCharacterMotor and ExampleCharacterController settings in the inspector?

    I will soon be releasing a v2.2.0 where -I think- this is fixed. I might have unintentionally fixed this while making small corrections for character movement networking, because now I can't repro it anymore. I definitely was able to see that problem before, though. If v2.2.0 does fix it, it's very possible that it fixed the first problem too

    I'm not sure I understand this one. Here's what I get with -10 gravity in the example scene: https://i.gyazo.com/664beeaedea9e40740a798ed98da6c0f.mp4

    I'm trying to do the same thing you're doing (jump against the wall as perpenticularly as possible), but I can't get the behaviour you're showing. Can you give me a screenshot of your KinematicCharacterMotor and ExampleCharacterController settings in the inspector?
    Here's what I'm seeing: https://i.gyazo.com/c2fd179fb2cb6f8e3f28e567cf49c876.mp4

    ________

    You Unity version would be useful to know too
     
    Last edited: Apr 7, 2018
  33. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Hi @PhilSA! I found your asset by accident and I think it might help me very well. But before I buy the asset, I have a few more questions:

    1. Does the controller only respond to moving platforms that are rigidbodies? Or can the controller also react on platforms controlled by an animator?

    2. I'm currently using the default character controller with Cinemachine. I have a Diablo-like top-down camera. Will the KCC also work with a top-down camera powered by Cinemachine?

    3. Can you say something about the performance on mobile devices? Let's say I'm only using one KCC at the same time and I'm running it on an iPhone 5 and also on an equivalent Android device (let's say Galaxy S3 or S4).

    4. Do you think it's hard to add a ledge walking system like this one?

    1.png

    5. Do you think it's hard to add an auto-jump-system like in 3D-Zelda games (jump automatically when you walk towards an edge)?

    Sorry for all the questions. All the feedback and the asset itself sound very convincing.

    Thank you in advance.
     
  34. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Moving platforms can theoretically be controlled by anything, since you can make various implementations of them (by inheriting from the "base" moving platform class).

    For example, right now the project has a moving platform script that is based on a math function over time, and in the upcoming v2.2.0 , there's one that is based on a Playables animation made in timeline ( video ). Making a moving platform script based on an Animator would be possible, and there is a section in the walkthrough that explains how you'd go about making custom moving platforms

    Yup

    Some customers have already tried KCC on mobile devices in that range and it runs well. KCC is made with a pretty rigorous focus on performance, and has several options you can disable

    In my opinion and experience, the best way to implement something like this is to disable the actual characterController script entirely while you are in the "walking on ledge" state, and do a custom movement script that handles just that specific case. However, whether you go with that approach or just implement it as an actual characterController movement state, both solutions would be fairly straightforward to implement

    You get access to all kinds of grounding information from the KinematicCharacterController, such as IsOnLedge, LedgeNormal, etc... So implementing a ledge jump would mostly just involve adding an upwards velocity when IsOnLedge is true
     
    Last edited: Apr 8, 2018
  35. iamtommo

    iamtommo

    Joined:
    Aug 25, 2017
    Posts:
    3
    Afternoon, @PhilSA

    Apologies if you have addressed this elsewhere, I may have missed it.

    I noticed the KinematicCharacterSystem uses a global singleton instance, which is causing some issues for my use case.

    I'm working with a networked codebase which is built so that the unity instance can be a client, a server, or both simultaneously. In the case where it's the client and the server, the client and server entities are ofcourse both controlled by the KC system and should not interact at all. The issue i'm having is that since the system is a singleton, i couldn't control the simulation for client and server separately without butchering this fantastic asset.

    I extracted the necessary pre-sim/sim/post-sim routines in the simulation call so i update only 1 motor, instead of all of them. This brought on a few new issues such as the 'Custom' interp routines using static fields and also needing to be extracted. I'm sure there are more of which you can perhaps imagine.

    I'm left at a point where i'm seeing very weird movement artifacts and it's becoming increasingly difficult to determine whether they stem from my butchered glue code or hidden side effects deep in the KCC call stack, or ofcourse the underlying networking. One example where predicted movement on the client differs strongly from the server simulation is falling, reaching position deltas of ~1 unit. Not sure if there's interference between the character simulations.

    Could we possibly see an update which 'encapsulates' the system and no longer relies on a singleton? If unlikely, would you mind outlining what you deem necessary to be extracted or perhaps what issues i should look out for?

    P.S. I checked out the KCC networking sample on github, but from what i can see it assumes either client or server, not both.

    Much appreciated.
     
    Last edited: Apr 8, 2018
  36. baumxyz

    baumxyz

    Joined:
    Mar 31, 2017
    Posts:
    107
    Thanks for your very informative answer. I just bought the asset and will try it out now :)
     
  37. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    In the networking example, the "Server" mode is in fact a server and a client at the same time. The thing is; in this architecture, all characters are simulated regardless of if you're a client, a server, or a client/server. This is because it allows for prediction based on last received inputs for each character

    (as a side note, I just submitted KCC v2.2.0 last night for review, and it contains the completed networking example will all the documentation and most of the missing features added)

    However, if you need to simulate different sets of characters independently, KinematicCharacterSystem has a version of the "Simulate" method that takes an array of motors (and movers) and simulates ONLY those. You just have to make sure to turn "KinematicCharacterSystem.AutoSimulation" off first. I'm under the impression that this would suit your situation, but let me know if not. I may not understand clearly what you mean by "the client and server entities [...] should not interact at all"

    The main reason why KinematicCharacterSystem acts like a singleton is that when KCC gets upgraded to use the new ECS and Job system, this is how things will have to be, and I want the transition to be as smooth as possible. In the ECS, you won't be able to have several "instances" of a same system. So it has to be able to work with only one instance. This is why I think calling "Simulate()" on a subset of characters is the way to go here
     
    Last edited: Apr 8, 2018
    LouisHong likes this.
  38. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    v2.2.0 is now out!

    The main changes are:
    • Networking example has been released (as part of the Walkthrough)
    • Added a “GroundDetectionExtraDistance” parameter to the motor, to allow ground snapping to reach further if needed (@PedroHN this will help with the issue you brought up to me)
    • Added a boat to the CharacterPlayground, to demonstrate an interesting use case for PhysicsMover. (and also because I've been watching Sea of Thieves videos and wondering if my character controller could handle that too!)
     
    maxaud and Petethegoat like this.
  39. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Re boats, my game is boat heavy and physics movers work well. Occasionally I get some local minima. One nice to have example for movers would be how to maintain a constant speed in relation to the surface you are on. Ie so if walk speed is 4, and the boat is moving S at a speed of 10, then if the character is going N it should move at a speed of 14 relative to the world and 4 relative to the platform.
     
  40. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    the motor gives you access to:
    • BaseVelocity: The velocity caused by your direct movement
    • AttachedRigidbodyVelocity: The velocity caused by the PhysicsMover/Rigidbody you're standing on
    • Velocity: Your total world velocity
    Using these, you can calculate the required velocity quite easily. In your example, "BaseVelocity" would always be 4, "AttachedRigidbodyVelocity" would be 10, and "Velocity" would be 14

    I should also specify that "UpdateVelocity()" always asks you to modify BaseVelocity, not the absolute worldspace velocity
     
  41. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    289
    I'm really liking the controller so far. I've run into a minor issue in the playground scene, however. At certain angles and locations when approaching the red BigMesh object, the character controller stops dead. Here's a gif:

    https://d.pr/free/i/ZX1kfE

    Oddly, if I stop pushing forward once stuck, the character advances a tiny bit before stopping, and can then continue forward. I didn't catch this behaviour in the gif, however.

    Edit: This also happens on the terrain in scene. I caught the weird stop-and-go behaviour this time:

    https://d.pr/free/v/dxoJTw

    Thanks for a great asset!
     
  42. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Thanks, someone else also brought up that problem to me and I'll look into it shortly.

    I think it might be due to the fact that PhysX queries don't work as expected when they hit an external edge of a non-manifold concave collider (which is something that probably shouldn't ever happen in a real game), but there may be ways to deal with that
     
  43. maxaud

    maxaud

    Joined:
    Feb 12, 2016
    Posts:
    177
    Thanks for the recent update. You rock.
     
  44. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    @CodeBison @kindingerlek
    It seems like the "getting stuck when walking on the terrain" bug is caused by the combination of the SafeMovement option on the motor, and the fact that PhysX queries return inaccurate results against edges of a non-closed concave mesh collider (which the terrain is)

    What happens is that the character's capsuleCasts will sometimes inaccurately determine the distance of hits against those edges, which will make the character move slightly inside the collider. When SafeMovement is turned on, any movement that would make the character be inside of another collider is canceled, which is why the character stays stuck in this case.

    I suggest simply turning off SafeMovement to solve this. The basic character controller code is "safe" enough as it is (meaning it won't go through any colliders), so most people probably wouldn't need SafeMovement anyway. I personally don't have it on in my projects. Turning it off will save you on performance, too.
     
  45. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    289
    Okay cool, good to know. I'll keep that setting in mind. Thanks!
     
  46. kindingerlek

    kindingerlek

    Joined:
    Jul 7, 2015
    Posts:
    10

    Wow man, thanks for the answer. I'll uncheck this option.

    One suggestion, maybe could be interesting: turn off this option by default, once you guarantee to disable it is safe enough for most projects. Another suggestion, document this issue of Nvidia PhysX in code as tooltip attribute, or in the main documentation.
     
  47. Petethegoat

    Petethegoat

    Joined:
    Jun 12, 2013
    Posts:
    39
    The userguide on the latest assetstore version cuts off during this sentence:
     
  48. Petethegoat

    Petethegoat

    Joined:
    Jun 12, 2013
    Posts:
    39
    I'm creating a climb/mantle, and it's basically functional, but I'm wondering if I need to do anything special to account for moving platforms.
    It works roughly like this:

    On climb input:
    1. do a bunch of character sweeps to check if we can climb
    2. create a ClimbQuery struct with a bool for success, and vectors for end position and velocity to reach the end point (using GetVelocityForMovePosition over a fixed time)
    3. if it was a success, transition to the climbing state, which disables collision solving and capsule collisions.
    Then, in UpdateVelocity, in the climbing state:
    1. set currentVelocity to our previously calculated climb velocity
    2. if we're within a small distance of the calculated end point, transition back to the default state and zero out our velocity.
    So immediately while typing this up, I realised that the distance calculation shouldn't work, but it mostly seems fine- I've used TransientPosition everywhere, is that inadvertently giving me the behaviour I want for moving platforms? I think it does, which is amazingly useful.

    Anyway, my real issue:
    during the climbing state, the attachedRigidbodyVelocity from the moving platform appears to freeze and stop updating, which means I lag behind the platform while climbing. This happens even if I use the attached rigidbody override when transitioning into my climbing state, so I'm wondering if the disabled collision solving causes it to stop updating, or if there's some other weird issue.

    Meant to be a bit more concise, sorry! If I can give you anything helpful let me know.
     
  49. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Good idea, I'll do that

    oops, will fix!
    In case anyone reading this is curious, the function to teleport is KinematicCharacterMotor.SetPosition()

    nice find, that's actually a bug. I'll be submitting an update to the store as soon as possible. As for your approach to climbing, seems like you've got the right idea
     
  50. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So I'm struggling getting getting decent performance. Editor vs builds don't make much difference. This is on the latest 2018 beta.

    The following is with 176 controllers in the real game scene, not isolated with nothing else running. I'm showing the high/low numbers that I see in the profiler. It bounces up and down quite a bit due to fixed update not being smooth.

    The physics calls account for a good chunk but not all. If I disable my controller, basically just don't set the rotation/velocity, times improve by around 15% or so.

    But it's not good enough to get to 60fps. Editor vs build makes very little difference.

    Ideally I'd like to disable collision checking for everything except grounding which is 80% of my use cases. I have various movement modes that have a mix of moving platforms and pathfinding vs non pathfinding. But most of the time I don't care about collision checking that's not directly related to grounding.

    Basically I'm thinking I have two options. Use another controller when I'm not on a moving platform, or customize this one so it doesn't do a bunch of checks I really don't need.

    Thoughts?

    upload_2018-4-15_18-26-20.png

    upload_2018-4-15_18-27-16.png