Search Unity

[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:
    160
    That's the first time I've seen these specific errors - and I can't seem to reproduce them either on my machine (at least not yet).
    Which version of Unity are you currently using? Do the errors also occur if you import the package into a new, blank Unity project?

    Please feel free to contact me directly via the official support email (support@j-ott.com) and I'll get back to you as soon as possible!
     
  2. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
  3. path123456

    path123456

    Joined:
    Mar 20, 2021
    Posts:
    7
    Are there mobile controls and ability to crouch i played the demo I found it lacked those also ability to sprint.
    The gravity flip is very cool
     
    Last edited: Sep 26, 2021
  4. Phenomonaut

    Phenomonaut

    Joined:
    Sep 30, 2012
    Posts:
    58
    Has anyone been able to get this to work with an Xbox controller and the new input system? I tried this tutorial and still nothing. Character movement works but no spinning the camera or jumping.
     
  5. Jigganis

    Jigganis

    Joined:
    Jun 19, 2019
    Posts:
    5
    Hey, I was just wondering, how extensively would I have to mod this engine for a skating game? Skateboarding OR inline. Trying to get a ballpark sense.
     
  6. Jigganis

    Jigganis

    Joined:
    Jun 19, 2019
    Posts:
    5
    My guess is that it would involve just making there be more inertia to turning and moving, ie you can't immediately turn 180 degrees or stop
     
  7. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    Unfortunately, the CMF package doesn't feature any crouching/sprinting functionality at the moment, but you could implement this by writing a script that adjusts the controller's 'Movement Speed' based on whether a crouch/sprint key is pressed, for example.

    Regarding mobile input: If you haven't already, I'd recommend checking out chapter 7 (page 36) in the user manual, which covers the basics of how to write custom input scripts (which would probably be the easiest way to implement mobile input).

    If you already completed the tutorial, then you should have an 'InputMaster' script, which you can now use to get input from - all that's left to do now is to make sure that the 'CharacterInput'/'CameraInput' scripts on the controller access that input (either by creating a custom input script, as shown in chapter 7 of the user manual, or by modifying the included input scripts in the package).

    I hope this helps!
    I think it really depends on how 'realistic' you want the controller to behave/steer. If you just need to "fake" some acceleration/decceleration, then you could implement this by smoothing the input going into the controller (i.e. modifying the input script).
    However, if you want something more complex, then you could also try to create a custom controller script (see chapter 8, page 39 in the user manual for an introduction).

    The best approach really depends on the type of gameplay you're aiming for - can you think of an existing game that features the type of skateboarding movement you want in your project?
     
  8. Jigganis

    Jigganis

    Joined:
    Jun 19, 2019
    Posts:
    5
    Hey Mr. Ott, thanks for the reply. I'm really just going for Jet Set Radio (or, like, ps1 Tony Hawk) level physics. As simple as possible--like just a little more inertia to turning. Turning shouldn't immediately turn you to the left, it should take a second of holding the left key for that to happen
     
    Last edited: Sep 27, 2021
  9. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    I see - for that use-case, it might be a good idea to implement some kind of acceleration/deceleration system directly into the controller code.
    Essentially, you'd create a new variable to store the current movement velocity of the controller and increment that velocity toward the player's input over time.

    Feel free to contact me directly via the official support email (support@j-ott.com) if you need any help setting this up.
     
  10. hrohibil

    hrohibil

    Joined:
    Apr 17, 2021
    Posts:
    198
    Hello
    Thank you for this awesome asset. It really looks so promising.

    I have a biped robot with a couple of animations. I wanted to add a controller to this.

    Also what is the simplest approach for me here .
    I want to use a third person perspective view and move the robot around and using my animators?
    Cheers
    Hamid
     
  11. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    I'd recommend starting with one of the 'blank' controller prefabs included in the project and position your character mesh inside the red capsule (you can delete the capsule afterwards).
    Then, you'd set up your animations like you would with any other controller (create an animator controller, create animation variables, create states and transitions, then update your animation variables with a custom C# script every frame).
    If you're interested, chapter 10 in the user manual has some information on how to get the necessary controller state information (current movement speed, grounded state, etc.).

    I hope this helps!
     
  12. dorusoftware

    dorusoftware

    Joined:
    Jul 5, 2012
    Posts:
    364
    There is any solution out of the box to get this up and running for the Unity new input system? Without me writing bunch of scripts and all :D

    I like how you can just drag and drop the prefabs and just works but I would love to do this with the new input system.

    Thanks, great asset btw
     
  13. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    Hi!

    Unfortunately, there's currently no way to implement the new input system without writing any code. That said, the code you'd actually have to write is fairly straightforward - and if you're using an input action map (for example), I'd suspect that maybe ~4-5 lines of code would be all you need.

    Feel free to contact me directly (support@j-ott.com) if you run into any problems!
     
  14. dorusoftware

    dorusoftware

    Joined:
    Jul 5, 2012
    Posts:
    364
    Ok, I will see if i manage to do it.

    But just for curiosity, why not update the asset to work with the new input system also?
     
  15. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    There's a few reasons for this, but the main ones are:

    1) The new input system is not included in new Unity projects by default, so importing any package that requires it will cause a whole lot of compile errors and will make the project unuseable until the new input system has been imported as well (and a complete restart of the editor is required).
    My concern here would be that (especially) new Unity users would have a hard time figuring this out.

    2) The documentation for the new input system has improved considerably lately, but it's still very rough around the edges and too technical for beginners to make sense of, unfortunately.
    To add to the confusion, a lot of the tutorials (on Youtube, etc.) are outdated (since the new input system is still in active development and changing a lot).

    3) There's just too many ways to use the new input system (getting input directly from devices, actions, action maps, the PlayerInput component, the PlayerInputManager component, using action callbacks, polling input using actions, generating input action scripts ...).
    Which makes it very difficult to decide which approach to use and to include in the asset by default.

    So far, my solution to dealing with this has been to modularize the controller and separate the input from the actual controller code, which makes it fairly easy to implement any kind of input system.

    And as far as I can tell, if users want to create custom input action maps (which seems to be the most popular way to use the system), they'll have to write custom C# code anyway, to instance their custom input actions inside the various scripts and enable them, as well as get input from them.

    I hope that helps explains it a bit!
     
  16. Mysterius

    Mysterius

    Joined:
    Aug 24, 2015
    Posts:
    11
    Hello JanOtt,

    I'm having trouble using CMF with moving platforms animated with the help of DoTween.

    I currently have a very simple elevator going upwards thanks to
    Code (CSharp):
    1. DOMove(new Vector3(0, 500, 0), 10);
    I'm using the default FirstPersonWalker prefab for testing and when I hop on the elevator everything gets jerky. The character end up passing through the floor of the elevator.

    I tried the simplest method I know : parenting FirstPersonWalker to the elevator when the player is inside. Even that doesn't help, movement is still jerky.

    I took a look at your moving platforms script but I don't see how to apply that to my elevator moving thanks to tweens.

    Any hint? :)


    Edit : here's what it looks like.
     
    Last edited: Oct 14, 2021 at 7:02 PM
  17. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    160
    It's a bit hard to say what specifically causing the glitches in your video, but just to provide a bit of context:
    The moving platform system included in the CMF package uses kinematic rigidbodies that are moved in FixedUpdate(), in combination with triggerzones (=colliders with 'isTrigger' enabled) on top of the platforms.

    Whenever a controller steps on a platform, it also enters the triggerzone - and every time the platform is moved, it checks whether there are any controllers in its zone and moves them as well (using the built-in 'MovePosition()' function of the controller's rigidbody).

    You might want to try adding a similar triggerzone system into your elevator setup - or maybe even use the CMF platforms (and modify them if needed).

    Also, generally speaking: Parenting (non-kinematic) rigidbodies to moving objects almost always results in glitches and physics problems, so I wouldn't recommend that approach.
     
unityunity