Search Unity

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

[Released] Character Movement Fundamentals - A Rigidbody-based Character Controller

Discussion in 'Assets and Asset Store' started by JanOtt, Jul 1, 2019.

  1. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Unfortunately, I can't promise that root motion support will come anytime soon, since it would require quite a lot of changes to the controller code (it's tricky to mix 'traditional' character movement with root motion in one controller script).

    However, if you need root motion mostly for ladder movement (and similar actions), the easiest way to go about it would be to simply turn off the controller as soon as the character starts climbing the ladder, handle all ladder movement using only root motion animations and turn the controller back on at the end of the ladder again (maybe reset the controller's position/rotation as well).

    I haven't tested this approach yet, but that's the theory at least.
     
  2. NPBirader

    NPBirader

    Joined:
    Feb 23, 2015
    Posts:
    20
    Hello. Im thinking of buying this pack. But before that, i have some questions.

    By reading the user manual and doing some research, i didnt understand qite right how the grounded movement/ movement on slopes works. Are you constantly projecting the movement onto the ground or are you „snaping“ the controller to the ground, based on you Raycast checks?

    Considering the last question about root motion. I think the problem could be solved by getting the velocity out of the root motion data itself in OnAnimatorMove() and then feeding it into your move function as a velocity. Could this be a possible way?

    And a more General question. Why using a Rigidbody? What speaks against the built-in Character Controller? What are the Pros and Cons of both approaches? What was your intention into using a Rigidbody?
     
  3. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Yes, the 'Mover' script is essentially 'snapping' the controller to the ground, based on the current raycast results.

    That's definitely the way I'd approach it as well, but the difficulties really start to show when it comes to handling jumping, falling and vertical movement in general. And of course, there's also the angular velocity from the root-motion animations that wouldn't work with the current camera setup.

    I'm sure there's a good way to implement root-motion with the 'CMF' system, but I'd need to do some tests first.

    Well, using a rigidbody has the benefit that your character will be able to properly collide and be affected by other colliders and rigidbodies in the scene - for example, something as simple as having a character being pushed around by another rigidbody can be quite difficult to implement with a 'kinematic' controller (like the built-in 'Character Controller' component).

    Rigidbody controllers can also be a lot more efficient (performance-wise), especially if they're used in greater numbers in the same scene.

    And then there's the limitation of not being able to rotate Unity's 'Character Controller' at all - that's not a limitation of 'kinematic' controllers in general, but it's a limitation of the built-in one for some reason.

    I hope this helps!
     
  4. Vmrll

    Vmrll

    Joined:
    Feb 23, 2019
    Posts:
    2
    Hi ! First of all thanks a lot for this great package !
    As a non-coder I was struggling with a controller I made of following a youtube tutorial, but this one handles movement and physics in a much smoother way !
    I just spent the day "migrating" my character rig/model and controller to the new format and now almost everything works ok now.

    One thing that was "bothering" me is that the character would keep on jumping when reaching the ground if the Jump key is held.

    So I looked at CharacterKeyboardInput.cs and replaced :

    Code (CSharp):
    1. return Input.GetKey(jumpKey);
    by

    Code (CSharp):
    1. return Input.GetKeyDown(jumpKey);
    Changing this seems to work fine, and now my character only jumps once even if I hold down the Jump key (at least for normal movement on a plane surface, I have not tried the moving platforms nor gravity tunnels).

    Just to be sure, is there any counter indication to do so ? Or is this a cheap "hack" ?
    If not, maybe this could be added as a preference so that this is editable from the inspector!

    Best !
     
  5. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi!

    The current version (2.0) doesn't really have a built-in way to stop the character from jumping continuously if the jump key is held down - but I'll try to add this in the next version (2.1).

    For the time being, there's a relatively straightforward way to add this functionality by slightly modifying the 'AdvancedWalkerController'. I already have a working implementation figured out, so if you're interested, please contact me at support@j-ott.com and I'll send you the file!

    Your current solution is fine, but unfortunately will bypass some of the jump code (specifically the part that allows a player to influence the jump height, based on how long they press down the jump key) - nothing game-breaking, but you still lose one of the controller's jump features.
     
    Vmrll likes this.
  6. Vmrll

    Vmrll

    Joined:
    Feb 23, 2019
    Posts:
    2
    Thanks for the reply !

    Ahh of course, yes that makes sense.

    I am interested. Email sent.

    Best !
     
  7. MAIKU_NORA

    MAIKU_NORA

    Joined:
    Jul 17, 2019
    Posts:
    16
    Hello, "using CMF;" doesn't work for me, I don't understand, unity can't find it.

    Thank you!
     
  8. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi!
    If you could maybe contact me at support@j-ott.com with more information about your project (which Unity version you're using, what your script looks like, [...]), I'll look into it and get back to you as soon as possible!
     
  9. MAIKU_NORA

    MAIKU_NORA

    Joined:
    Jul 17, 2019
    Posts:
    16
    Done!

    Thank you!
     
  10. lolhans

    lolhans

    Joined:
    Dec 12, 2019
    Posts:
    7
    is there any way to use this controller for multiplayer with the pun2 asset? im trying to get it running, would be a very nice thing (Y)
     
  11. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    I'm not exactly an expert on networked multiplayer, but quite a few people have already used the package in multiplayer prototypes - so you might want to ask around on the Discord server (https://discord.gg/SGNKbB7)!

    Or you can contact me via email as well! I probably won't be able to help out too much with the technical details of a PUN2 implementation, but I could try to outline the basic steps required!
     
  12. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    205
    Yes, it's very simple to get it going. Join the discord if you want and I'd be happy to help you!
     
  13. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    466
    I am using this asset for a TPS on my character (obviously) but of course the feet either penetrate the ground or float above depending on the situation. Does anyone know of any good foot IK systems which can be easily integrated? The capsule collider does not hit the ground, this is a custom solution, so I can't see many IK solutions that would easily work. Ideas?
     
  14. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    205
    I always assume FinalIK is the best answer to these questions, but I've never personally used it. It does seem to be the go-to solution for all things IK.
     
  15. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    One very straightforward way to implement footIK with the package would be to raycast down from the respective foot bones to find the ground normal and position.

    Or you could project the foot bones' position to a plane defined by the currrently detected ground position and ground normal of the 'Mover' (with a bit of vector math) - which is probably slightly less expensive (in terms of performance) but less accurate as well.

    You should then be able to pass this position and normal to whatever IK system you're using, ideally.
    I havent' really looked too much into footIK systems so far, but I'd assume they all work by setting a desired foot position and rotation, at least internally?
     
  16. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    Are you going to include spherical gravity?
     
  17. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    A common way to implement double-jumps (or multi-jumps in general) is to implement a variable that tracks the remaining jumps ("jumpsLeft", for example), which is reset to a specific value, whenever the character is grounded (for a double jump, you'd set it to '2', for example).

    Then, you'd include a condition somewhere in your jump logic that lets the character jump if either A) they're currently grounded or B) "jumpsLeft" > 0. And every time a jump is initiated, 'jumpsLeft' is decreased by one.

    There's also other ways to implement it, of course - it depends a bit on what kind of gameplay you're going for.

    Spherical gravity is actually already possible with the package, you just need to write some simple rotation code to continually rotate the controller so its 'up' direction is always aligned with the current gravity direction (which points to the planet's core).
    But I think I'll include a simple example scene in one of the next updates eventually, since a lot of people seem to be interested in this.
     
    angel_m likes this.
  18. splitdev

    splitdev

    Joined:
    Oct 24, 2018
    Posts:
    9
    Hi Jan,
    great asset, thanks for all your work :)

    We need some advice:
    We're making a little multiplayer space ship game and for movement on the space ship/planets/space stations we're using your AdvancedWalkerController/ThirdPersonWalker_C which is working great.
    But the player is able to leave the ship and do space walks using some kind of jetpack movement.
    Our jetpack movement consists of a rigidbody + applying relative force/torque and using the mouse for yaw/pitch.

    How would you handle switching controllers? We tried disabling your scripts (and there are quite some) and storing/restoring state but we got some problems:
    - the rigidbody has wrong rotations as we need to disable rotation freeze when switching back to your controller
    - camera is jumping as your TurnTowardsTransform kicks in when switching back
    - we are rotating the gameobject itself and not ModelRoot so we need to reorientate the outer gameobject
    - your camera control conflicts with ours (look vs yaw/pitch and how to position the camera on switching)
    - some minor other things (like constant falling animation as we are not grounded, so many extra scripts on the player, ..)

    Each of them is solvable (like camera lerping, saving and restoring your state, adding "space flight" to the Mover script, etc.) but tedious ;)
    As we are using multiplayer simple prefab switching is unfortunately not that easy as the player object has authority and is the local player :(
    What is from your point of view the best/easiest solution? Maybe someone else had a similar problem? Maybe we overlooked sth.? Maybe there is an easy method for disabling your scripts and reenabling them + restoring state?

    Cheers!
     
  19. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi!

    Just based on your description, I'd definitely recommend implementing some kind of prefab-switching system, if at all possible.
    Just like you already said, turning a walker controller into a completely different type of gameobject (in terms of movement) is a lot of tedious work, and very prone to bugs as well.

    On the other hand, using two separate controller prefabs and switching between them when necessary is a lot cleaner and easier to implement - and it's a lot easier to sync over the network as well!

    To solve the 'authority' issue with your player object, you could have an empty root gameobject, that holds all the net-work relevant functions and parent the two controller prefabs to that gameobject (think of it like a "meta-player" prefab that holds multiple controller prefabs inside it).

    The only thing I'd maybe suggest implementing separately would be a camera switching system, so you can smoothly transition between the two controllers at runtime. A very common way to implement this would be to have empty "camera sockets" on each controller, that the camera can be parented to, for example.

    That's my initial thoughts on how to approach this, at least - please feel free to contact me directly via email (support@j-ott.com) anytime, if you have any further questions!
     
  20. splitdev

    splitdev

    Joined:
    Oct 24, 2018
    Posts:
    9
    Hi and thank you very much for your answer :)

    I already thought you might suggest prefab switching, but it is always good to have some second advice.
    So we might have to rewrite our player handling/controlling a bit, back to the drawing board I guess o_O

    Thank you for offering support, I will contact you if I have further questions.

    Cheers!
     
  21. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Hello JanOtt !

    I bought the asset last week and I am quite happy with it, however I notived few things and I wanted to have your input on this.

    With the 'ThirdPersonWalker' ( all 3 of them) from each version ( blanked, simplified or animated ) when I am moving around, it seems that the rigidbody is 'stuttering'. Not with huge values, but we can clearly see the capsule is doing a movement of 'forward backward'.
    This reminds me the issues I had when I made my characterController, when something is updating on the Update() where it should actually be in FixedUpdate().
    Of course I have no doubt you know all of this, and this issue is probably linked to something else, but before continuing working with this asset I wanted to check with you how I could get a 'smooth' movement as intended ?

    Thank you ! :)
     
  22. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi!

    Thanks for reaching out!
    I can't really replicate the 'stuttering' issue you're describing on my own computer right now, but there's a few settings in a Unity project (like the 'Fixed Timestep' setting in the 'Time' options, for example) that can influence the way the internal physics behave, which in turn could also affect the visuals of the character.

    It's possible that this is also happening in your project, since by default, there really shouldn't be any stuttering at all with the included controller prefabs - if you could maybe contact me directly via 'support@j-ott.com' with a few more details about your project and Unity version, I'll try my best to help you troubleshoot the issue!
     
  23. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Hello JanOtt !

    No problem I sent you an email,

    Cheers !
     
  24. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    I have tried quite a few character controller, and while they are pretty nice, i always end up with limitations or having to work my way around issues, thus using more time and if i had coded a movement controller myself.

    I like the fact that this asset is focused only on movement and doesn't tackle too many things at once, because this is likely to cause less problems for me when integrating with other assets etc..

    I just purchased it and will be using it shortly, and even though both would be easy to setup, I would definitely like to cast my vote for adding cinemachine support and the ability to move on click mouse movement(i already have a custom script, but would be nice anyway :) )

    Thanks !
     
  25. baroseiro

    baroseiro

    Joined:
    Aug 30, 2019
    Posts:
    3
    Hi,
    I am using this controller but as @SpyrosUn wrote, still requires some development and some limitations actually don't need to exist. So, just asking if the author can for instance, convert the abstract classes into interfaces (i.e. CharacterInput , CameraInput ). These abstract classes are not implementing anything common but simply providing an "interface" for implementation. By having this as interfaces, I could make my own implementation class implementing multiple interfaces, for instance an InputManager which implements CharacterInput and CameraInput interfaces. Also the Mover class plus sensor class sounds and looks a bit weird, it looks like we could have a single GroundColliderController instead.

    Might sound a bit negative, but I like this controller, so thanks for the good work so far.

    Just my 2 cents for further improvement, thanks :)
     
  26. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Thanks for the feedback! I'll definitely try to add a 'click-to-move' example setup in one of the next few updates!

    Regarding Cinemachine support: Could you maybe elaborate a bit on how you'd want to use Cinemachine with the asset (a few example use-cases would be really helpful)?
    I'm mainly asking because technically, you can already use Cinemachine with the 'CMF' controller prefabs by just deleting the 'camera' component down in the controller's hierarchy and replacing it with one of Cinemachine's virtual cameras (for example).

    Don't worry, all feedback is always welcome!

    Turning the 'CharacterInput' and 'CameraInput' class into interfaces sounds like a great idea, I'll definitely look into that for one of the next updates.
    I'll have to run some tests whether this is also feasible with some of the other abstract classes in the package, though.

    Merging the 'Mover' and 'Sensor' class into one component is something I've considered lately as well!
    I'll probably try to streamline and refactor the whole ground detection system for a possible future version 3.0 anyway, so merging them back together at that point might be a good idea.
     
  27. TheWarper

    TheWarper

    Joined:
    Nov 3, 2013
    Posts:
    112
    Heyo, so I'm trying to use the SmoothPosition.ResetCurrentPosition() to sync the cam up with a player teleport like one line after I change its position, but it still smooths its way there. It avoids the smoothing if I just use this following code,

    void SmoothUpdate() {
    ResetCurrentPosition();
    }

    but then I lose the smoothing all together, obviously.

    How can I modify to get the teleport but not lose the smoothing?

    Btw, great asset and everything, still one of my favs.
     
  28. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    205
    As long as that doesn't mean one 1000-line script :)
     
  29. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    107
  30. fvaguirre

    fvaguirre

    Joined:
    May 2, 2020
    Posts:
    2
    Hi, I've been reading through the source code, and trying to piece this together. I am also trying to implement a way to switch between first and third person on a key press but I am having trouble. Would you mind helping me out?
     
  31. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Just based on your description, it sounds like you may only be resetting one of the 'SmoothPosition' components on the controller (it usually comes with two separate ones, one for 'ModelRoot' and 'CameraRoot' respectively).

    Alternatively, an even simpler solution would be to disable the entire controller (by using the 'gameObject.SetActive(true/false)' function), then move the controller to its new position and then enable the controller again.

    This works because the smoothing scripts have some built-in code to handle being enabled/disabled.
    Please let me know if this solves the issue!
     
    TheWarper likes this.
  32. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    To be completely honest, I wouldn't recommend trying to combine these two movement systems into one - as far as I can tell, the package you linked to is heavily based on root-motion animations, while the 'CMF' package doesn't support root-motion at all (at least not yet).
    And then there's the difficulty of handling two completely different codebases, which probably require quite a lot of modifications to make them compatible with each other.

    Is there any particular reason why you can't use the 'Climbing System' package as-is? Based on the Asset Store description, it looks like this asset already comes with its own character controller.

    Sure, I can help you set up a camera switch - if you could maybe contact me directly at 'support@j-ott.com' with a bit more information, I'll get back to you as soon as possible!
     
    ml785 likes this.
  33. TheWarper

    TheWarper

    Joined:
    Nov 3, 2013
    Posts:
    112
    Wow, that did the trick! I was not looking at that at all, thank you!

    btw, after teleport I used the following code to grab both 'SmoothPosition' components and reset:

    foreach(SmoothPosition smoothPosition in c.GetComponentsInChildren<SmoothPosition>())
    smoothPosition.ResetCurrentPosition();
     
  34. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    205
    I doubt I can help any better than @JanOtt , but of course I'll try. I do check the discord a lot more than this forum, just fyi.
     
  35. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    Hi ! Sure, in terms of Cinemachine I'd say it would be rather useful to have some template camera views, for topdown, rpg, etc. Of course I can do that myself too, just saying :D Cinemachine is just too powerful and i kinda think it should be the default camera for controllers, but it's just an extra thing, it's definitely not bothering me as is.
     
    ml785 likes this.
  36. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    By the way, you may want to have a check on whether the camera requires mouse control. At the moment you have this line :

    if(cameraInput == null)
    Debug.LogWarning("No camera input script has been attached to this gameobject", this.gameObject);

    so when i remove the camera mouse input component(cause i dont need mouse movement), I am getting this annoying warning. I am basically just commenting it out at the moment.
     
  37. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    I see, I'll try to look into Cinemachine a bit more for a future update and see if I can find a good way to maybe integrate it into the package.

    Are you replacing the 'Camera Mouse Input' component with a custom input component? Because there always needs to be some kind of 'Camera Input' script attached, or else the 'CameraController' won't do anything (no input = no camera rotation).

    Or, in case you don't need any camera rotation in your game at all, you could also remove the whole 'Camera Controller' component as well, since it doesn't really serve any function without an input script, anyway.
     
    ml785 likes this.
  38. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    Ah, I can remove the whole thing ? ok. I thought it was required and i just tried removing the mouse input controller.

    I guess i will need some zoom or or later, but i can probably just add that later
     
  39. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    Hi again @JanOtt,
    I was messing a bit with creating a click to move script and while it works i am getting some weird camera behavior.

    The click to move script is super simple :

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.AI;
    3.  
    4. public class ClickToMove : MonoBehaviour
    5. {
    6.     void Update()
    7.     {
    8.         if (Input.GetMouseButtonDown(0))
    9.         {
    10.             MoveToCursor();
    11.         }
    12.     }
    13.  
    14.     private void MoveToCursor()
    15.     {
    16.         Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    17.         RaycastHit hit;
    18.         bool hasHit = Physics.Raycast(ray, out hit);
    19.         if (hasHit)
    20.         {
    21.             GetComponent<NavMeshAgent>().destination = hit.point;
    22.         }
    23.     }
    24. }
    I am using the top down movement controller prefab. It works just fine with the keyboard buttons, but the behavior is different when clicking on the nav mesh. The character does indeed move, but it doesn't change direction. Instead the whole camera rotates.

    I am attaching a video that shows how it is behaving. In the video i am first moving with the keyboard buttons and then via clicking on the plane. You will notice very weird behavior in the later case.

    Also notice, when the game first plays and i am attempting to move right, the character remains stationary and only starts moving when switching direction. I thought that this may have some conflict with the nav mesh agent and sure enough when i disabled it, it worked fine.

    By the way the click to move script works fine. I tested it on a default Camera. I think it must have something to do with the topdown camera rig. I guess I could also just create my own camera rig, but would like to be able to use the asset ones if possible.

    Here is the video :


    Any idea on how to fix this would be really welcome :)

    Thanks !
     
    Last edited: May 14, 2020
  40. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Just generally speaking, it's not really possible to combine navmesh agents and (non-kinematic) rigidbodies (like the 'CMF' controllers) in Unity - according to the offical Unity docs:
    Based on the video, I think that's what's happening in your scene as well.

    So, to implement a 'click-to-move' mechanic with the 'CMF' package, you'll need to actually pass the movement direction to the controller, to move it toward the desired target position.

    One way to do this would be to put your raycasting code into a custom 'Character Input' script and calculate the necessary horizontal and vertical input values based on the character's current position and the target position.
    This approach might be a good solution, if you want to be able to use the 'WASD' keys and your 'click-to-move' input interchangeably.

    Another approach might be to write a custom controller component and replace the default 'AdvancedWalkerController' with it - but that's a bit more work on the coding side (although you'd have complete control over the movement that way).

    I can help you set up either option, but it would probably be easier to discuss this via email - could you maybe contact me at 'support@j-ott.com' directly, if that's okay with you?
     
  41. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    144
    Yes, that makes sense, but I think you can calculate the velocity of the agent and adjust the character walking through the controller. I think this is why it will be useful for the asset to have a walk on click option, cause otherwise you have to make quite a few adjustments manually to make it work. I think the best solution would be to adjust AdvancedWalkerController, yes. Not sure I want to spend the time on this now though, I will probably go for a different ready solution just to avoid spending time for no reason, but thanks a lot for offering to help :D
     
  42. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    107
    Do you have general advice on how to achieve Wall Jump with this controller? I've been scouring the Internet for wall jump tutorials to try with the asset but most I find are CharacterController-based.
     
  43. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Generally speaking, wall-jumping can be broken down like this:
    1. Detect whether the character is currently in contact with a (suitable) wall - you can achieve this with raycasts, trigger zones or even Unity's 'OnCollision()' events, for example.
    2. Check whether the player has initiated a wall-jump (by pressing the 'jump' key, for example).
    3. Calculate the velocity that the character should have after the wall-jump (maybe by reflecting the current velocity of the controller off the wall surface).
    4. Apply the new velocity.
    The 'AddMomentum()' function of the controller script is actually a very good way to quickly add forces to the controller for situations like this.

    I've recently written a very basic wall-jump example script for another customer, so if you're interested in that, please feel free to contact me via 'support@j-ott.com' and I can send you the file!
     
    ml785 likes this.
  44. usamatanveer522

    usamatanveer522

    Joined:
    Jan 7, 2020
    Posts:
    1
    Hi.. I have
    Character Movement Fundamental.. i want to ask how can i use these scripts to move my own character. please help me with it i tried but my character won't move
     
  45. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi. I've just noticed that you also contacted me directly via email, so I'll respond to you there!
     
  46. splitdev

    splitdev

    Joined:
    Oct 24, 2018
    Posts:
    9
    HI Jan,

    I have another question: How can I handle fast moving platforms or using your characters in a ship (like sea of thieves or star citizen)?
    For example if I set the speed of the moving platform in your demo level to about 200 the player will be thrown off :eek:
    And in my case I want to use the controller inside a moving space ship in multiplayer.

    Any ideas or best practices for this use case? :)

    Cheers!
     
  47. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi,

    For special gameplay situations like characters moving on another moving rigidbody, the best solution would probably be to calculate the ship's current velocity every FixedUpdate() and add that velocity to each of the controllers on the ship, after the controller scripts have been run (you'll need to adjust the settings in the 'Script Execution Order' menu for this).

    Depending on your specific game, you might also need to deal with ship rotation (and applying that to the controllers), as well as making sure that the characters can't push the ship they're standing on.

    I hope that helps! Please feel free to contact me via 'support@j-ott.com' if you have any other questions!
     
  48. splitdev

    splitdev

    Joined:
    Oct 24, 2018
    Posts:
    9
    Thank you, will try this :)
     
  49. Napoleonite

    Napoleonite

    Joined:
    Mar 15, 2015
    Posts:
    30
    The asset looks interesting.

    How useful is this asset for zero gravity zones like space when you walk outside of your spaceship-gravity? I imagine this asset to be useful for inside a spaceship but once you walk out you need some kind of a flying-character.
    Or should I just disable this controller and using a zero-gravity one for such cases and just keep switch back and forth?

    Also, does this asset work with odd gravity like round planets?
     
    Last edited: Jun 10, 2020
  50. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    180
    Hi!

    Generally, I'd recommend switching controllers once your character leaves the spaceship - mostly because you probably would want to use completely different character controls in a zero-g environment.

    The 'CMF' package actually allows you to change between different controller scripts at runtime, so one possible implementation would be to disable the default 'AdvancedWalkerController' component as soon as your character enters space and enable a separate 'SpaceWalkerController' component instead (and vice-versa).

    Or, alternatively, you could switch to a completely different character prefab altogether, of course.

    Regarding planetary gravity: That's definitely possible as well - all you need for this to work is a script that continually rotates the character to align it to the center of the planet.
    I have a very simple example setup ready that I could send you - just contact me at 'support@j-ott.com' if you're interested!
     
    Napoleonite likes this.