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:
    13

    Hi everyone!​

    I'd like to introduce you to an asset I've just released called Character Movement Fundamentals, a rigidbody-based character movement system for Unity.

    Put simply, it's a collection of scripts, components and prefabs that will help you quickly set up characters that can move around and react to any 3D game environment in a physically believable way.

    Everything in this package is designed to be as versatile and adaptable as possible - whether you're creating a fast-paced first-person shooter, an atmospheric third-person adventure game or a 2.5D sidescoller, this package will provide all the necessary fundamentals you need.
    Features:

    - In-depth user manual.

    - Fully documented source code.

    - Versatile, highly customizable character controller system.

    The included character controller can handle all kinds of terrain, smoothly walks up and down slopes and stairs without losing ground contact and can even slide down slopes that are too steep.

    In addition to that, it can be rotated freely at runtime, allowing for
    interesting gameplay possibilities (walking on ceilings or on a miniature planet [...]).

    To optimize your game for any type of platform, you can choose from three different ground detection methods.

    Finally, all movement-related properties (movement speed, air control, jump speed, step height [...]) can be adjusted to fit any type of gameplay.

    - All-purpose camera system
    The included camera system is well suited for any type of camera perspective (first-person, third-person, top-down [...]) and features built-in camera rotation smoothing, invertible input axes and adjustable vertical camera angle limits.

    - Two example scenes that showcase all the possibilities of the package.

    - 12 ready-to-use controller prefabs, that can "drag'n'dropped" into any scene and just work, no further setup required.

    - A collection of basic environment building blocks and a fully rigged and animated low-poly character model, both of which are great for quick prototyping.

    ----------​
    If you have any questions about this asset and its playable demo or if you'd like to give me some feedback (which is always very much appreciated), please feel free to do so, either here in the forums or directly via email at support@j-ott.com.

    Thanks for your time and have a great day!
    - Jan
     

    Attached Files:

    Last edited: Jul 30, 2019
    chelnok and JamesArndt like this.
  2. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    179
    this looks really well done, very versatile. 2 quick questions, would I be able to run 2 character controllers and cameras at the same time? and does the camera have a ability to zoom in/switch position?
     
  3. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Thanks p_hergott!

    You can easily run multiple character controllers in the same scene! Here's an example I just threw together:

    Splitscreen.png

    For the split-screen effect, all you need to do is adjust the 'Viewport Rect' settings of the player cameras, which only takes a few seconds.

    There's no 'zoom script' included in the package (yet), but implementing a zoom function would be fairly easy. If you're interested, just send a mail to support@j-ott.com and I'll gladly help out with that.

    Regarding switching camera positions, I'd need a bit more information about what you're trying to do - do you want to have two characters in a scene sharing one camera (that can switch between these two characters) or something else entirely?
     
  4. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    179
    Well im 3/4 done a split screen xbox project. And the one thing i keep revisiting is the camera controller. For zoom, im thinking, for a over the should aim mode.
     
  5. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    179
    and can the camera target be set dynamically?
    also while im asking hahaha, I see the controller has a jump, does it also have a sprint? (my controller im using I built myself, so doing minor modifiers and stuff shouldn't be a problem.
     
  6. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    179
    haha I almost feel bad for all the questions, but I do truly like what I see though, looking through the images, video and manual. it really does look like an outstanding controller.
     
  7. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Thanks for the kind words!
    Ah, now I get it! This kind of zooming/aiming can easily be implemented with this asset. It basically comes down to changing the camera's offset and field-of-view a bit whenever the player is holding down the 'aim down' button.
    As of right now (version 1.1), all cameras are child objects of the character controllers. However, since the whole system is very modular, you could easily make the camera its own independent gameobject and have it follow different targets dynamically.
    Currently, there's no sprint functionality implemented in the controllers (there could be in the future, if there's enough interest in more advanced movement). The scripts are very adaptable though, so adding sprinting should be fairly straightforward, depending on how complex your sprinting system needs to be.

    Like I said before, if you happen to run into any problems with the asset or need help implementing something specific, just feel free to contact me via the support email and I'll try to answer in more detail.
     
  8. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    I'm happy to announce that 'Character Movement Fundamentals' has just been upgraded to version 1.1. Here's a list of the changes:

    - Replaced old showcase scene with new version (now with a proper controller selection menu).
    - Polished controller prefab settings.
    - Replaced 'ApplicationControl' and 'ChangeControllerType' scripts with new 'DemoMenu' script, which will now handle switching between different controller prefabs.
    - Added 'DisableShadows', 'FPSCounter' and 'PlayerData' scripts, all of which are used in the new showcase scene.
    - Decreased scene light intensity to '0.7'.
    - Removed all (unnecessary) 'Showcase' controller prefabs, all example scenes now use the controller prefabs included in the project.
    - Added 'MouseCursorLock' script, which provides basic mouse cursor locking functionality. Old (unstable) 'FocusMouse' script was removed.
    - Updated user manual to reflect changes.

    This update mostly consists of streamlining the showcase scene(s) and all included controller prefabs, but there's also some new content in there (a proper mouse locking script, for example).
     
  9. tequyla

    tequyla

    Joined:
    Jul 22, 2012
    Posts:
    327
    Hello,

    concerning the top down view, is it possible to add click and point move ?

    thanks.

    Teq
     
  10. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    There's currently no "point-and-click" type controller included in the package. But it's definitely possible to implement that kind of movement with this package by writing some custom movement logic.

    I'll definitely add a dedicated controller prefab for this in a future update if there's a demand for it, though!
     
  11. Sehlor

    Sehlor

    Joined:
    Feb 10, 2012
    Posts:
    187
    I can vouch for click to move for Top-Down, otherwise its an excellent product!
     
  12. HellGate94

    HellGate94

    Joined:
    Sep 21, 2017
    Posts:
    10
    Hello.

    Looks interesting, but can you tell me a bit more on how it is done? I assume it's a kinematic not dynamic character controller so the interactions with dynamics are reconstructed my hand. i'm using a seesaw test to check if character controllers are suitable for me. would you be so kind and show me how it acts when the character jumps on a dynamic seesaw and with a heavy object falling on the other end while standing on it (and maybe one where he walks on an unstable physics object like a chain bridge)?

    thanks
     
    Last edited: Aug 4, 2019
  13. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Well, seems like there is a demand, so I'll be sure to sure to look into it for the next update!

    Put very simply, the character movement system in this package is a combination of (dynamic) rigidbody physics and a raycast-based ground detection system to get the best of both worlds, so to speak.

    Regarding your seesaw test: As of right now, this package is probably not the best choice for the type of environment interaction you're looking for. By default, the controllers don't exert any downwards force on the rigidbodies they're standing on (which would be necessary for a seesaw to work). Likewise, the controllers don't feature an inertia system yet (also necessary for the seesaw physics).

    I can think of few ways to convincingly "fake" the physics interaction you're looking for, but a 100% physics driven rigidbody controller might be a better choice here.

    Hope that helps!
     
  14. HellGate94

    HellGate94

    Joined:
    Sep 21, 2017
    Posts:
    10
    well no other character controller i tested so far passed this test so thats good info (for you, for me it means i need to keep searching :D)

    making a dynamic rigidbody controller is a pain and i pretty much gave up already because the physics engine causes several bugs and without source code i cant adjust / fix it.

    but oh well. good luck with your asset!
     
  15. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    119
    What sort of moving platforms does it support and how does it handle the orientation of moving platforms?

    e.g. if I'm inside a school bus that is a physics based vehicle, can I walk around the inside of the bus, and what happens to character orientation when the bus is turning?
     
  16. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Currently, all included controller prefabs support kinematic rigidbody platforms that use trigger zones (trigger colliders) to determine if a character is standing on top of them. As of now, the orientation/rotation of the moving platform does not affect the rotation of the character standing on it.

    I'm currently doing some tests to see if I can come up with a system that doesn't require trigger zones and could also handle rotating the character at the same time. So far, I haven't found a good solution yet, but I'll keep at it.
    That sounds like a tricky game mechanic to implement. Since the bus would need to be a dynamic rigidbody, this is currently not possible with this package.

    Do you have an example of an existing game that implemented this mechanic successfully? I'd love to see this in action!
     
  17. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    Hi there and thank you for you great product. I am using your first person prefab and would like to know if I can make the camera movement only happen when a mouse button is down instead of all the time as it does now?

    I’d need the user to be able to move his mouse in the game without moving the view.

    Many thanks and best wishes
     
  18. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Hi jh092!
    That's easily done! All you need to do is create a custom script, extend the CameraController script and override its GetInput() function. There's also a chapter in the manual on this topic (4.4.2 - Overriding the Camera Controller, page 31), if you're interested.

    Check out the file I attached below called "CustomCameraController": It's a very basic example of how to implement that kind of camera behaviour. Just import it into your project and use it to replace the regular camera controller component in one of the prefabs (or you might want to create a new custom prefab first).

    In the 'FirstPersonWalker', you'll find the camera controller script under 'FirstPersonWalker -> CameraRoot -> CameraControls'.

    Side note: Make sure there's only one camera controller script attached to the gameobject at the same time.

    I hope that helps! If you have any further questions (or if anything's not working correctly), please feel free to contact me via the support email (support@j-ott.com). Or just reply in this thread, both options work for me!
     

    Attached Files:

  19. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    Ah I see, thank you so much for the super fast response, this is exactly what I needed too.

    John
     
  20. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    7
    Hi again, sorry I do have one more question if I may...

    I'm trying to save the player position and rotation so that I can save and load my game levels, returning back to where I was.

    I can save the position just using the FirstPersonWalker transform.position that's fine, but my issue is with the rotation. I have tried many different things using the FirstPersonWalker/CameraRoot/CameraControls.transform.rotation but not having much success.

    For rotation, on save I'm using:

    CameraControls.transform.rotation.eulerAngles.x
    CameraControls.transform.rotation.eulerAngles.y - 360

    And then on load I'm using the SetCustomRotation with the above two values.

    Looks like the y is correct but the x is always wrong...

    Hope that all makes sense :)
     
  21. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    That should be fairly straightforward to implement. Since the rotation of 'CameraControls' is directly controlled by the 'CameraController' component ('CustomCameraController', in your case), you'll need to save (and load) the rotation values of the component instead of directly setting the transform's rotation.

    I'd love to go more into detail, since your question kind of requires a few more in-depth explanations. Would it be okay for you if we continue this by email? Just send me a copy of your comment to support@j-ott.com and I'll get back to you as soon as possible.
     
  22. revanaii

    revanaii

    Joined:
    Jun 13, 2017
    Posts:
    7
    Sooo for anyone who needs sprinting
    Code (CSharp):
    1.  
    2. public class ExtendedCameraWalkerController : CameraWalkerController
    3. {
    4.    float defaultMovementSpeed;
    5.    public float sprintingSpeed;
    6.    public KeyCode sprintingKeyCode;
    7.    public bool IsSprinting{ get; protected set; }
    8.    public UnityEvent onSprintBegan = new UnityEvent();
    9.    public UnityEvent onSprintEnded = new UnityEvent();
    10.  
    11.    protected override void Setup()
    12.    {
    13.       base.Setup();
    14.       defaultMovementSpeed = movementSpeed;
    15.    }
    16.  
    17.    void LateUpdate()
    18.    {
    19.       var wasSprinting = IsSprinting;
    20.       IsSprinting = Input.GetKey(sprintingKeyCode);
    21.       movementSpeed = IsSprinting ? sprintingSpeed : defaultMovementSpeed;
    22.       if(!wasSprinting && IsSprinting) onSprintBegan.Invoke();
    23.       if(wasSprinting && !IsSprinting) onSprintEnded.Invoke();
    24.    }
    25. }
    26.  
     
    Last edited: Aug 20, 2019 at 2:26 PM
  23. EstudioVR

    EstudioVR

    Joined:
    Jul 26, 2013
    Posts:
    60
    is it mobile ready?
     
  24. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    The controllers should run fine on mobile devices, performance wise. In addition to that, you can override the controllers' input calculation to implement any user input system - mobile input (via virtual joysticks, for example) included.

    I'm currently looking into including mobile controls for the next update, though. If you need mobile input out-of-the-box, you might want to wait for version 1.2, which should be ready sometime in September.

    @revanaii
    Cool, thanks for sharing that movement code! Are the UnityEvents in your code for animation purposes?
     
    EstudioVR likes this.
  25. revanaii

    revanaii

    Joined:
    Jun 13, 2017
    Posts:
    7
    JanOtt
    Yep, to hook up camera FOV tweening, particles - that kind of stuff. And thx for the great asset, so far it's the best controller I've found in terms of out-of-the box quality and complexity under the hood.
     
  26. JanOtt

    JanOtt

    Joined:
    Apr 23, 2019
    Posts:
    13
    Thanks, very glad to hear that!