Search Unity

[RELEASED] Easy Character Movement 2

Discussion in 'Assets and Asset Store' started by Krull, May 5, 2021.

  1. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    Hi @Krull
    The Cinemachine "CM Third-Person Example Scene" uses the mouse to look around, the right joystick on gamepad does not work. In "Third Person Controller Example Scene" both the mouse and right gamepad stick can be used to look around. What is the best way for me to get the right stick to look around in the Cinemachine example scene? Do i need to implement the ThirdPersonController script or something else? Thanks
     
  2. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    The Third Person Controller Example Scene (TP) has a few extra things that the Cinemachine (CM) one does not have.

    In TP, go look at the Main Camera It has a third person camera controller behaviour that moves the camera around. That controller is getting driven by the ThirdPersonController behaviour that is in the ECM2_CharacterController game object. The ThirdPersonController behavior is getting input from the PlayerInput behavior also on the same game object. Finally, the PlayerInput behavior is reading the controller inputs via the ECM2_ThirdPerson_InputActions input action asset.

    CM isn't reading the input (via ECM2_ThirdPerson_InputActions) of the controller--only the mouse. So, try opening up CMThirdPersonCharacter.cs and look at the method InitPlayerInput(). You'll see that is where the mouse input is getting hooked up.

    You could try adding in the controller input ("Controller Look") and see if that works. Maybe even just switching out "Mouse Look" with "Controller Look" would work. I didn't try it (I have no gamepad sitting here next to me), but that is where I'd start.
     
    johnlumsdendeveloper and Krull like this.
  3. VR_Junkie

    VR_Junkie

    Joined:
    Nov 26, 2016
    Posts:
    77
    Hello, when I play an animation (root motion disabled) and the animation involves hovering it activates the jump in the animator controller. How do I stop this functionality?
     
  4. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    Thanks, changing "Mouse Look" to "Controller Look" worked! Initially it was moving very slowly, but changing the "Camera Turn Sensitivity" from 0.1 to 1 fixed this. However, it does have a lot of jitter when looking around. Annoyingly, the reason why i chose this product was because my own cinemachine implementation was jittering... Maybe I'll leave CM well alone, as the TP worked fine. UPDATE - Actually, if i "Maximise On Play", leave sensitivity as 0.1, its works great. No jitter anymore, and the look speed is good. It is only when i play non maximised does the look around become very very slow. It seems like sensitiviy here has to be 1, to match the sensitivity of Maxmised at 0.1....

    Any idea why in VSCode i'm getting red underlined errors? This file is unchanged from what is in the package.
     

    Attached Files:

    Last edited: Feb 16, 2022
  5. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @Garganturod,

    Thank you for your suggestion, I'll do some tests and see how viable it is without causing side effects to other users.

    Also, if you leave your character input actions unassigned it wont do any input related code, so you can control your character as your game needs.

    Regards,
    Krull
     
  6. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @johnlumsdendeveloper,

    Yes, cinemachine examples do not implement controller support as it is focused on cinemachine integration only, however you can copy the controller related code from the ThirdPersonCharacter to the Cinemachine example as @Garganturod already commented.

    About the error message, make sure you include the input system namespace in your controller

    Code (CSharp):
    1. using UnityEngine.InputSystem;
    Or probably related to visual studio code integration.

    Regards,
    Krull
     
    johnlumsdendeveloper likes this.
  7. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    I tried updating to the new system for my project but ran into a lot of problems so I reverted for now.

    If I could, I'd like to request a little help with an older version if possible. I'm making an action hack and slash type game. I have an enemy juggling scenario that can happen by launching the character upwards. Works fine, but I'm wanting to freeze the enemy mid air when taking damage. Should I approach this in a specific way? Something like setting gravity to zero or setting the rigidbody to kinematic? I just want to know if ECM has something built in to help with this.
     
  8. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @Rin-Dev

    Sure it's possible, you can set its movement mode to None, and (pre kinematic version) will turn character into a kinematic rigidbody saving its current velocity, later when you need to resume its movement, you set its movement mode to Falling and it will restore saved velocity and continue as usual.

    Another way is setting its movement mode to Flying, however it won't immediately freeze character as it will carry its momentum as it will be affected by its flying movement mode settings, but should work too.

    Regards,
    Krull
     
  9. Thane_5

    Thane_5

    Joined:
    Sep 22, 2020
    Posts:
    4
    Hey, i was wondering if there is a way to make the character stick to moving platforms that are animated through an animation clip. I don't know if this is super unncommon or even impossible, but i think it would be easier to handle for some people, especially when quickly designing a level.
     
  10. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    I hear what you are saying. It's more that Rewired complains that the new input system is simply installed even if I have it set to both/old in the Player settings. Honestly, ECM2 is more important to my little project than Rewired, so I had thought about just using the Unity input system. For now, though, I'm deleting all ECM2 examples, and commenting out things in several other files (Character, AgentCharacter, some template editor thing, etc.).

    Not a huge issue at all. It's just something I do when a new version comes out.
     
    Krull likes this.
  11. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Sure, you can move the platforms as your game needs, just make sure to set its Update Mode to Animate Physics. Please take a look at the 4.2 Animated Platforms for a working example.
     
  12. fr1ar

    fr1ar

    Joined:
    Apr 10, 2021
    Posts:
    1
    Hi @Krull
    Don't you have any plans to integrate ECM2 with Netcode?
     
  13. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @fr1ar,
    In short, yes, I do plan to add basic network related examples as part of future updates.
     
  14. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    576
    Oh that's interesting! Are you looking to use Mirror or PUN2?
     
  15. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Definitely adding those two, probably fish-net will be included too. But please keep in mind examples will mostly be get-started.
     
    MuntyMcFly and Pixelith like this.
  16. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    Yeah, I'm trying to get it to work with fish networking right now. If anyone has any advice, please share :)
     
  17. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    FYI, there is a fish networking example using the Unity character controller. So far, the CharacterMovement has been nearly a clean drop-in replacement. I haven't done any of the full ECM2 Character stuff (jumping, etc) yet though.
     
    Krull likes this.
  18. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    @Krull Can you please advise how bad my implementation of the following is, and what would actually be the best practice here.

    I want the players capsule collider to shrink when he jumps, as currently the collider goes far higher than the players model shows.

    What i therefore have done is this.

    In CharacterMovement file made "_height" as "public float _height;"

    Created a copy of the ThirdPersonCharacter class (TPC), added a variable called "public CharacterMovement cm;"

    In the inspecter i dragged in the CharacterMovement component into TPC.

    In TPC, i overrode the OnJumped() method, and created this:

    Code (CSharp):
    1. protected override void OnJumped() {
    2.     cm._height = 0.5f;
    3.     StartCoroutine(ResetColliderHeight());
    4. }
    5.  
    6. IEnumerator ResetColliderHeight() {
    7.     yield return new WaitForSeconds(0.50f);
    8.     cm._height = 1.85f;
    9. }
    This very crudely shrinks the collider height to 0.5 when the player jumps, then after 0.5 seconds sets it back to 1.85. Ideally i want it to smoothly do the shrinking, but for now its just a proof of concept.

    I did try and override OnLanded but it doesn't work as i guess the ground detection doesn't get triggered when the collider is small.

    This can't be the correct way to do it can it?

    Thanks!
     
  19. PyrokidSosa

    PyrokidSosa

    Joined:
    Apr 7, 2020
    Posts:
    1
    Hi there @Krull

    I just bought ECM2 for use! Looks really good so far, just what i need! The gameplay examples are pretty interesting, but i noticed that those features aren't in the default character script, and was wondering how I'd go about combining some of them?

    For example, I'm trying to make a character that can dash, target lock, and use twin-stick aiming in some contexts. would it be a case of just copying and pasting sections of the scripts used in the examples into a template character script? and if so what parts would I need to copy-n-paste?

    (I'm sorry if these questions seem weird, I'm just a little overwhelmed (I'm primarily an artist, programming is kinda hard for me lol))
     
  20. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,403
    Best character controller (have tried several others..)!

    was doing some quick tests on placing 3rd person prefab on the planet demo scene, but for some reason it stops animating the character, if disable the default "ThirdPersonCharacter" and add "MyCharacter" (from the planet demo capsule controller prefab). Seems that move is always 0,0,0 in the UnityCharacterAnimator at that point..

    Didn't manage to track it down where it gets the proper animator values when ThirdPersonCharacter is used.. but not with that MyCharacter that overrides input and rotation..

    upload_2022-2-25_19-30-19.png
     
  21. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    Whether this is related to something i found, i do not know, but i had a very similar issue where my player wasn't moving. In the UnityCharacterAnimator script there is this:

    Code (CSharp):
    1. float forwardAmount = _character.useRootMotion && _character.GetRootMotionController()
    2.                 ? move.z
    3.                 : Mathf.InverseLerp(0.0f, _character.GetMaxSpeed(), _character.GetSpeed());
    forwardAmount kept being 0 for me, which in turn meant i couldnt move the character. What fixed it for me was changing this:
    Code (CSharp):
    1.  _character.GetMaxSpeed()
    and replacing it with the number 6.
    My character script had a Max Walk Speed set to 6, but it wasn't being picked up.

    Obviously this is just a workaround to get things moving again, I never did actually resolve why GetMaxSpeed() was 0.
     
  22. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,403
    nice, thanks - that was it!
     
  23. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    Cool, just out of interest, does your falling animation work for you? I had to do another workaround for that.
     
  24. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,403
    jumping does work - didn't actually test whether there was separate fall thing yet..
    But please post if can, if i hit that issue also :)
     
  25. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    For me, running off the side of an object or coming down from a jump, the player would fall but there was no animation playing (like legs or arms moving). A random fix i did was in UnityCharacterAnimator script, where you see:

    if (_character.IsFalling())

    Just put the following code underneath:
    print("aaa");

    For some reason it makes the falling animation work... I really don't understand why though and it could just be me, so it would be interesting to see if you come across the same thing.

    I have a funny feeling both of the fixes I have mentioned means I have probably messed up somewhere along the line :)
     
  26. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @johnlumsdendeveloper,

    Variables with an underscore prefix are private or protected and are for class internal usage, instead you should use the radius, height, etc properties or methods like: SetDimensions or SetHeight to directly modify your character's volume.

    As you can see in the Character Crouching method, where it uses the CharacterMovement SetHeight method to modify the character's height.
     
    johnlumsdendeveloper likes this.
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @PyrokidSosa,

    About your question:

    Yes, ECM2 is based on inheritance, and in order to add extra functionality to a default character some programming is required.

    In ECM2 you create a custom Character (e.g. 'MarioCharacter') extending one of the 'base' character classes (Character, FirstPersonCharacter, ThirdPersonCharacter, etc), and use your new 'MarioCharacter' custom character class to add your game required mechanics on top of default ecm2 functionality. As you can see, the examples follow that approach.

    So in your case, yes you are correct, you should add to your 'MarioCharacter' class the needed mechanics from the examples, so in the end your 'MarioCharacter' will be able to perform those added mechanics plus default ECM2 ones like walking, running, crouching, etc.
     
    PyrokidSosa likes this.
  28. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @mgear,

    Thank you :D

    A Character will not use animation at all unless you enable root motion in that case, a Character will use the animation velocity to drive character's movement instead of the procedurally generated one.

    Worth note if using Root Motion, please add the RootMotionController component to your model (where Animator resides), as this is responsible for feeding the animation velocity to the Character and the CharacterMovement component.

    Are you using root motion?
     
  29. ElevenGame

    ElevenGame

    Joined:
    Jun 13, 2016
    Posts:
    146
    Hello @Krull,
    I am using ECM2 in my game and It works absolutely great so far! :)
    Do you have any pointers how you would do head bobbing for the first person character?
     
  30. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @ElevenGame,

    Thank you, happy to hear it!

    Some games prefer to simulate it by animating the weapon instead of actually animating the camera, as could cause some sickness.

    If you want to animate the camera using the FirstPersonCharacter, I suggest you animate the Root GameObject to simulate walking / running, so you have full control of it and even trigger events to play footsteps from your animations.
     
    ElevenGame likes this.
  31. jcporcel

    jcporcel

    Joined:
    Jan 18, 2014
    Posts:
    3
    I have found a little glitch while trying to change the height of a character and I´m not sure if it´s only a Unity problem.

    I just created a fresh new project and imported the character controller from the package manager as usual. But, when I try to change the height and radius on the Movement component, only the radius gets updated the collider component. When the game starts the collider turns the correct size on awake and everything seem to be ok.
    Here I am changing the radius just fine, then not being able to update the height and then playing the game to show that the collider soddenly turns the correct size when the game starts.



    I thought it might be some problem with my current version of unity (2020.2.30f1), so I deleted the "Easy Character Movemenent 2" folder and instead of importing it from the package manager I copied it directly from another unity project and the radius/height started to work normally, updating both radius and height on the Movement component updates the Collider component as usual. This old version of the character controller was downloaded from the package manager on Feb 7, if this is of any use.

    I'm posting here because if the old version is working fine, maybe its not just me that is having this glitch.
    (Other than this small thing, I've been working with the asset for about 6 months now and its just fantastic. One of the best new additions was the flat base, just what my platformer needed! )
     
    Krull likes this.
  32. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @jcporcel,

    Thank you for reporting it!

    And yes, I can confirm this is a bug in the 1.1.6 version, causing CharacterMovement SetDimensions and SetHeight not updating Collider size in Editor.

    I uploaded a fixed version (v1.1.7) to the store, in the mean time, please modify the functions in the CharacterMovement component as follows:

    Code (CSharp):
    1. public void SetDimensions(float characterRadius, float characterHeight)
    2. {
    3.     _radius = Mathf.Max(characterRadius, 0.0f);
    4.     _height = Mathf.Max(characterHeight, characterRadius * 2.0f);
    5.  
    6.     MakeCapsule(_radius, _height, out _capsuleCenter, out _capsuleBottomCenter, out _capsuleTopCenter);
    7.  
    8. #if UNITY_EDITOR
    9.     if (_capsuleCollider == null)
    10.         _capsuleCollider = GetComponent<CapsuleCollider>();
    11. #endif
    12.  
    13.     if (_capsuleCollider)
    14.     {
    15.         _capsuleCollider.radius = _radius;
    16.         _capsuleCollider.height = _height;
    17.         _capsuleCollider.center = _capsuleCenter;
    18.     }
    19. }
    20.  
    21. public void SetHeight(float characterHeight)
    22. {
    23.     _height = Mathf.Max(characterHeight, _radius * 2.0f);
    24.  
    25.     MakeCapsule(_radius, _height, out _capsuleCenter, out _capsuleBottomCenter, out _capsuleTopCenter);
    26.  
    27. #if UNITY_EDITOR
    28.     if (_capsuleCollider == null)
    29.         _capsuleCollider = GetComponent<CapsuleCollider>();
    30. #endif
    31.  
    32.     if (_capsuleCollider)
    33.     {
    34.         _capsuleCollider.height = _height;
    35.         _capsuleCollider.center = _capsuleCenter;
    36.     }
    37. }
    38.  
    Regards,
    Krull
     
    Last edited: Mar 2, 2022
    jcporcel likes this.
  33. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    So, I got the full Character and main demo scene stuff to work with Fish Networking, but I cannot really advise anyone to do it the way I did. Basically, I am having the server to everything and the clients are just kind of like viewing it. More specifically, all the physics are all server side.

    Anyway, since I'm just doing a < 10 player LAN kind of hobby game, this will probably work for me.

    I'm posting, because if I can get it to work, then anyone can :)
     
    Krull likes this.
  34. jcporcel

    jcporcel

    Joined:
    Jan 18, 2014
    Posts:
    3
    Thanks!. As always, the fixes come almost real time!
    I will download the new version right now!
     
    Krull likes this.
  35. DJ_Design

    DJ_Design

    Joined:
    Mar 14, 2013
    Posts:
    124


    Hello! I'm just getting started after moving from ECM1- the transition has been really smooth and I'm really thankful to have come across this asset. I think the inspiration from Ue4 but making it as accessible as we're used to in unity as I read is a great idea, I only wish the networking traveled with it! :(

    Right now I'm working within Photon's newest product (free to develop under 20) "Fusion" which is a state transfer tick-based netcode framework that is just nearing release state.

    A couple of questions, Krull! (edit, had the wrong name)

    1. When you say: includes a custom simulation example using 2 methods, one fully Fixed timestep, and another using a semi-fixed timestep so no interpolation is needed.
    I'm looking for this now, I can't seem to find it- could you break it down exactly where these examples could be found?
    (and if you have any general feedback or tips to raise for integrating your package in a tick-based environment, please share this as well!)

    2. Do you have any plans to provide an example of your movement in a multiplayer environment (such as fusion) in the near future? I understand it's an undertaking, though with the post being a couple of months old would like to be aware of any hope coming down the pipe.

    I think both communities would benefit from such a collaboration, working towards my own goals right now as I said searching for the simulation examples but please consider this an option going forward! :)

    Right now they are building on their own Kinematic controller while fantastic in a multiplayer sense- it's a long way off from being accessible to what the average user expects (especially coming from pun if you're familiar, which is being directly replaced by fusion Shared model)
    Pun was the standard go-to for many developers and asset authors for multiplayer solutions for its ease of use-
    I thought if Mirror or Unity's new netcode for gameobjects was to be considered for an example integration I would raise that point of photon- especially now should be #1 consideration IMHO- (not an employee! :p)

    3. And finally, nothing network-related working with AI; what would be the recommended setup?
    I see you check for Input and return null if none is found, would I use blank input and feed move direction manually? Curious what your thoughts are on this.

    Thank you for such a great movement package it's been a great experience, looking forward to hearing from you!
     
    Last edited: Mar 4, 2022
    Krull likes this.
  36. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @DJ_Design,

    First of all thank you for updating to ECM2!

    I agree with you about the networking, unfortunately the lack of a standardized Unity native solution affected this decision.

    About your questions:

    Thank you for pointing it out! as actually the example using a Character was missing during the Folder restructure update and only included the CharacterMovement example (Easy Character Movement 2\Character Movement\Examples\4.- Custom Simulation).

    I'll add it as part of a next update, in the meantime, you can find attached below.

    Yes, as commented before I plan to add some getting started examples with major Unity Networking solutions, like Mirror, PUN2, etc.

    I am aware of Fusion and honestly it seems pretty impressive, unfortunately at this moment I have not deeply tested it but definitely something I plan to do.

    Well for AI, you could start using the included CharacterAgent which extends a Character adding Navigation (NavMesh based) capabilities and add a MoveToLocation function to issue Agent movement.

    Its code is fully commented and should serve as a starting point in case you would like to support third-party AI solutions. In the end to make a character follow a path (ai generated, spline etc), all you have to do is set its movement direction accordly, for example the CharacterAgent uses the NavMeshAgent desiredVelocity to keep moving the character along its computed path.

    Thank you very much :D

    Warm regards,
    Oscar
     

    Attached Files:

    DJ_Design likes this.
  37. DJ_Design

    DJ_Design

    Joined:
    Mar 14, 2013
    Posts:
    124

    Hello and thanks for getting back to me Krull, I think I understand how AI will work now.
    Because we rely on odd gravity directions, using a navmesh will limit us a bit in that regard- but as I'm reading it sounds like the CharacterAgent simply uses directional guidance and the controller handles the rest, so that should be no problem I was probably overthinking that, glad that's sorted.


    Thanks for clearing this up and sharing- will dive into this asap, cheers!

    It also sounds promising what may come down the line for multiplayer, which is exciting not just for me I'm sure..
    Many would appreciate this I have no doubt.

    Looking forward to the future with ECM2! :)
     
    Krull likes this.
  38. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    102
    I noticed that launchCharacter can override the Vertical velocity. Is there any other ways to do that?
     
  39. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Sure, you can freely modify the CharacterMovement velocity property, actually that's what LaunchCharacter function internally does.

    For example, to cancel the velocity vertical component in an up-right (not rotated) character just zero its Y value.
     
  40. MuntyMcFly

    MuntyMcFly

    Joined:
    Sep 29, 2016
    Posts:
    46
    Hello @Krull :)
    I was reading through this forum (bought your asset recently) and was wondering if you ever made the video you mention in this post? I would really love to see that process I have a game currently that uses the starter asset controller and would love to upgrade my player instead of needing to do much of a rewrite + fix animations(using the defaults for now).
     
  41. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @MuntyMcFly

    Thank you for purchasing it!

    About your question, unfortunately not yet, however to replace the Unity Starter Assets built-in character controller with CharacterMovement component, it's pretty straightforward as you can see in the attached ThirdPersonController.

    This is the default third person controller script from starter assets, but replacing the built in cc with cm. Just make sure to add the Character Movement component to your player.

    Additionally, I strongly suggest following the character movement walkthrough as it will serve you to get a better understanding of it and take full advantage of it.

    Kind Regards,
    Krull
     

    Attached Files:

    MuntyMcFly likes this.
  42. Sapien_

    Sapien_

    Joined:
    Mar 5, 2018
    Posts:
    102
    Hey again @Krull thanks for the reply, I may have missed it but where is it to configure which surfaces is walkable and which is not? I want it where the character can't walk on invisible walls.
     
    Last edited: Mar 9, 2022
  43. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Sure, you add the SlopeLimitBehavior component to your invisible walls and set those as Not Walkable and set the CharacterMovement SLope Limit Override to true.

    Additionally, you can make use of the CharacterMovement Collision Callbacks, in particular the CollisionBehaviorCallback.

    The CollisionBehaviorCallback it's a powerful mechanism to influence the character’s behavior, or in other words how it should proceed when a collision occurs. Using a combination of bitwise flags you can fine tune the collision behavior overriding the default one in a performant and practical way.

    For example, using the CollisionBehaviorCallback you can decide if the collided object should be walkable or not independently of the character’s slopeLimit, allow / prevent the perch behavior, determine if the character can step on and even determine if can use it as a moving platform or not, etc.

    Please take a look at the CharacterMovement Walkthrough example #10 - Callbacks (CharacterMovement\Walkthrough) for an example of this and other available callback functions.
     
    MuntyMcFly and Sapien_ like this.
  44. SRx734

    SRx734

    Joined:
    Sep 4, 2018
    Posts:
    8
    Hi Krull,

    Is it possible to have a flat top for characters? In the side scroller demo the character will bounce away horizontally when colliding with the corner of a platform while jumping. I think a flat top option could be useful to avoid situation like this.
     
  45. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @SRx734,

    Thank you for your suggestion!

    I agree with you, the flat top is a good idea and will prevent that from happening. I'll add it to next update TODO's list.

    Regards,
    Krull
     
  46. One_Learning_Man

    One_Learning_Man

    Joined:
    Sep 30, 2021
    Posts:
    81
    Oh man, I am very excited to see this for Mirror and FishNet. I am making a coop third person game and would love to see some more great resources from you.
     
    MuntyMcFly and Krull like this.
  47. Fabbs

    Fabbs

    Joined:
    Dec 2, 2013
    Posts:
    43
    Hi, Im trying to rotate with a platform, the character only picks up the rotating platforms rotation above a certain speed, which makes a slow yawing boat for example moving on its own with the character facing local forward, once the yawing speed picks up the character moves with the boat. Any clues?
     
  48. johnlumsdendeveloper

    johnlumsdendeveloper

    Joined:
    Jul 27, 2021
    Posts:
    15
    I'm using Third Person Character, player is controlled with left stick, cinemachine camera with right stick.
    If i use SetRotationMode(RotationMode.None);, the player cannot rotate, but the camera can still be move around (which is fine), but if i use SetMovementMode(MovementMode.None); both the player movement and the camera movement are fixed. How do i go about fixing the player movement (left stick), but allowing camera movement (right stick)? Is there another Mode which needs setting?
    2nd question, how would i use RotationMode in an if statement (i.e. how do i check if the RotationMode is set as None as an example).
    Thanks!
     
  49. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hi @Fabbs ,

    Mmm, does this happen with demo characters? Are you using a custom character? Make sure you enable the Impart Platform Movement, Impart Platform Rotation and Impart Platform Velocity properties.

    Additionally, how is your platform animated? For example, if using animation, please set your Animator's update mode to Animate Physics.
     
  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    770
    Hello John,

    Yes, setting the MovementMode to None basically disables the character , so it won't rotate or move.

    I suggest you in your custom Character override the Handle Input method and use a 'flag' to control where is allowed to move the character and when is not, for example:

    Code (CSharp):
    1. public bool isCharacterAllowedToMove = true;
    2.  
    3. protected override void HandleInput()
    4. {
    5.     // Handle camera related input
    6.  
    7.     HandleCameraInput();
    8.  
    9.     // Poll movement InputAction
    10.  
    11.     Vector2 movementInput = GetMovementInput();
    12.  
    13.     // Add input movement relative to camera look direction
    14.  
    15.     Vector3 movementDirection = Vector3.zero;
    16.  
    17.     if (isCharacterAllowedToMove)
    18.     {
    19.         // If allowed, update movement direction
    20.  
    21.         movementDirection += Vector3.right * movementInput.x;
    22.         movementDirection += Vector3.forward * movementInput.y;
    23.      
    24.         movementDirection = movementDirection.relativeTo(cameraTransform);
    25.     }
    26.  
    27.     SetMovementDirection(movementDirection);
    28. }

    You can get the Character's current rotation mode using the GetRotationMode() method, for example:

    Code (CSharp):
    1. // Get character's current rotation mode
    2.  
    3. RotationMode rotationMode = GetRotationMode();
    4.  
    5. if (rotationMode == RotationMode.None)
    6. {
    7.     // Do something here...
    8. }
     
    johnlumsdendeveloper likes this.