Search Unity

[RELEASED] Easy Character Movement

Discussion in 'Assets and Asset Store' started by Krull, Apr 21, 2016.

  1. cursedtoast

    cursedtoast

    Joined:
    Apr 27, 2018
    Posts:
    62
    Is there any way to prevent the controller from sliding along walls? For example, if I'm walking straight into a wall and keep moving, the controller will just slide to the left or right. Ideally, I would like movement to just not process.
     
  2. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @cursedtoast,

    I am afraid not in current version, as the current implementation does not 'look ahead' , this version will detect the character's current position and evaluate the ground below us, eg: is valid, invalid, is a step, is a ledge, etc, and project the velocity depending of current ground status. However this would not detect / handle 'walls' as your current case.

    The good news (as commented in previous posts), is the new version of ECM, (available soon) it's a completely rewrite of current ECM and implements a full Collide and Slide algorithm (as described here and other papers), and definitely improves the current ECM version while keeping the easy of usage and many new fetures!

    Regards,
    Krull
     
    cursedtoast likes this.
  3. Xulain-SineSpace

    Xulain-SineSpace

    Joined:
    Oct 14, 2017
    Posts:
    26
    How do you get mouse look working when you haven't installed the project setting?.
    It works fine when I do import those setting but I dont want to overwrite them on this particular project I'm working on now.
     
  4. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Xulain

    While ECM does not need the included project settings, it uses the default input axes for the mouse, "Mouse X" and "Mouse Y", so you could add those to the input axes or modify the MouseLook LookRotation method to replace the default input.

    Regards,
    Krull
     
  5. anpShawn

    anpShawn

    Joined:
    Oct 1, 2012
    Posts:
    18
    Hi @Krull , thanks for ECM. I'm currently using it to control a 2d character in a 3d world.
    I'm wondering if you had a suggestion for how to detect edge boundaries. You can see in my screenshot that the character can fall off the world if she walks too far to the left:

    Untitled-2.jpg

    I can place an invisible mesh here, or I can try to dynamically generate one around the edges. Both of these could be tedious.

    I was brainstorming a solution where I raycast down from the edges of the ECM controller and if the ray doesn't touch anything then I need to prevent ECM's movement in that direction. Do you think this would integrate with ECM's collision model at all, or would I need to hack/break things? After looking at all of the functions in the base ECM class, I'm not exactly sure where to fit this kind of logic in, if at all. What approach would you take?
    Thanks!
     
  6. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Is it possible to have it so the player is walking against an edge whilst holding a 'walk' key, the character controller could slide along the edge/ledge (as long as it's a certain height) without falling? The original Tomb Raider games used to do this, but it's hard to do with the built-in charcatercontroller without firing lots of raycasts and using ProjectOnPlane. It would also be useful to have as a default for enemies like the original Doom games did, the monsters would just slide along edges as they followed you.
     
  7. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Afro-Ninja,

    By default an ECM character can detect where it is standing on, such as flat ground, slopes, steps, ledges, etc. All this ground info is accessible through the CharacterMovement properties such as isGrounded, isOnPlatform, isOnLedgeSolidSide, etc.

    Having said, the CharacterMovement includes a helper function:

    Code (csharp):
    1. public bool ComputeGroundHit(Vector3 probingPosition, Quaternion probingRotation, out GroundHit groundHitInfo, float scanDistance = Mathf.Infinity)
    This funcions is the same used to perform the ground detection, however as you can see, you can pass an arbitrary position and rotation, so you can use that one to scan the ground at a different position than your character's current position.

    For example, in your case if your game is 2D, you can use the above function to check to your character's sides (left / right) or just a fixed distance along your character's moving direction, and use the returned GroundHit info, to stop your character's movement in that direction.

    Let me know if you require any further help.

    Regards,
    Krull
     
  8. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @Zebbi

    Not quite sure If I totally understand it, however ECM includes a parameter ledge offset, this allows to stand on a ledge up to this ledge offset distance without falling, as old 2D games (mario, mega man, etc) do when a character stand on a ledge without falling.

    By other hand, if you set the ledge offset to zero, the character will slide off the ledge as soon as it is detected.

    Could you provide me an example of this feature so I can better understand it?

    Regards,
    Krull
     
    Zebbi likes this.
  9. anpShawn

    anpShawn

    Joined:
    Oct 1, 2012
    Posts:
    18
    Thanks @Krull, that's a really good start. I'm still having a bit of difficulty deciding the best step of the process to use this function. I can attempt to either predict ECM's next position and halt movement based on that, or I can react to the current position and try to reset to the "last valid" position. Both seem to produce inconsistent/jerky results, but I'm still working on it.

    If I wish to go the "reactive" route, it looks like my only option is to place my own code inside of LateFixedUpdate() in the CharacterMovement class. It seems you use this function to perform final tweaks in a similar fashion?

    Alternatively if I wish to "predict" ECM's next position I can read the current moveDirection, velocity, or even make a call to ECM's own "CalcDesiredVelocity", but these only give me an idea of where the rigidbody is trying to go, not necessarily where it will be.

    I think I may actually be trying to accomplish the same thing that @Zebbi asked about: as the character pushes up against an "invisible" edge it should have the same behavior as if an actual invisible collider were present (sliding along the edge smoothly)

    I will continue with more experiments but I'm just curious which path you might take to try and achieve this yourself?

    EDIT: After doing a lot of testing today I think the best option might be to simply place invisible bounding blocks around the edge of my level. I was hoping to find an automated solution but it's a lot more difficult than I anticipated.
     
    Last edited: Nov 25, 2020
  10. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Here's an example of legde/edge walking on Tomb Raider (sorry about the black at the start for a few seconds): https://i.imgur.com/I0s2eok.mp4

    Here's an example of Doom's monsters, they look like they walk away from the edge a bit too, but I'm primarily looking to have monsters slide along the edge as they're tracking the player: https://i.imgur.com/NX3vhhv.mp4

    I've done a similar thing with Unity's CharacterController using a bunch of raycasts and ProjectOnPlane, but I've never gotten it really perfect and I'd love to have the functionality built-in to controller!
     
  11. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Afro-Ninja and @Zebbi

    Thanks for example, yes I have a better understanding of it now.

    A possible solution for this, as commented to Afro-Ninja, is 'look-ahead' and react to incoming ledges, in this case deflect movement.

    For example, the method I suggested to Afro-Ninja, the code can be in the BaseCharacterController Move method (after movement.move) or directly modifying the CharacterMovement Move method; no need for the LateFixedUpdate coroutine, as in our case, will be modifying the character's velocity, while the LateFixedUpdate mainly modify the Character's position in a 'non-visible' way and taking advantage of the rigidbody interpolation.

    For a 2D implementation, I think could be as follows:
    • Compute the character's next position, eg: nextPosition = transform.position + movement.velocity * Time.deltaTime.
    • Use the ComputeGroundHit to downcast at this nextPosition.
    • If nextPosition is on empty space, the character will fall and stop its movement completely (safe case)
    • However, if the nextPosition is a ledge (ComputeGroundHit result), compute an orthogonal blocking normal (an invisible wall), using the ledge ground normal and cross products.
    • Last, project the Character's velocity on this blocking normal (Vector3.ProjectOnPlane) to stop the movement against this 'invisible wall'
    Worth note the above is not tested, but in theory should work and / or serve as a starting point, however a more robust solution is to first simulate the character's movement (casting along its velocity) and react to collisions and special cases like this, found during its movement, this is know as collide and slide algorithm, however its no trivial to correctly implement it.

    Yes its a nice feature to have. The good news is the next version of ECM (hopefully to be released in early days of January) will make full use of the CollideAndSlide algorithm, and this "Can Walk off Ledge" feature is planned to be included too, so please stay tuned :)

    Regards,
    Krull
     
    Zebbi likes this.
  12. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    That sounds amazing, it would be really useful!!
     
    Krull likes this.
  13. Xulain-SineSpace

    Xulain-SineSpace

    Joined:
    Oct 14, 2017
    Posts:
    26
    Those were already added so I guess its something else in my project stopping it working. Is a shame as I bought this asset for testing project in unity as my projects get uploaded to Sinespace which Is like vrchat so no controller needed after upload but I am having more success just writing the code myself. This was meant to save me time.
     
  14. anpShawn

    anpShawn

    Joined:
    Oct 1, 2012
    Posts:
    18
    Thanks for the info @Krull. I feel better knowing that what I'm trying to accomplish has a name (collide and slide) and is more complicated than expected. I'm interested to see how the new version of ECM shapes up. Is it purely a backend rewrite? would I be able to import the updated version into my current project and expect to see the same collision behavior I've already implemented with the previous version of ECM?
     
  15. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Afro-Ninja,

    Well the new ECM version, is precisely that, a complete new version (eg: ECM 2), written from scratch, but following the same design goals as ECM, a robust Character controller, where users can build their game mechanics on top of it.

    Having said that, while this new version is a complete new product, it will follow the same development procedure as the current version, for example, create your custom controller extending the 'Base' controller, however it's not a direct port. IMHO this new version is much easier to use, however it's not a transparent update for existing projects.

    As previously discussed, it's an upgrade (basically a different product), and is up to users to decide if they want to upgrade (I suggest to) or keep using the current ECM version.

    Well it depends if you have modified any of the core ECM code, but without a doubt the new ECM collision detection and response is an upgrade of the current version, so yes, you can expect the same collision behavior.

    Best regards,
    Krull
     
  16. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    Is this a paid update or just a regular update that is a totally different architecture? Also, is there an ETA?
     
    cursedtoast likes this.
  17. cursedtoast

    cursedtoast

    Joined:
    Apr 27, 2018
    Posts:
    62
    Seconding this. Very curious. I'm still early enough in writing out my game core/toolsets that a full upgrade would be do-able. Very curious on the ETA and if this is something I'll need to buy or not, so I can try to plan ahead with the budget.
     
  18. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Zebbi and @cursedtoast

    Yes, it will be a paid upgrade, however current users will just have to pay the price difference (price still to be set), additionally will include a grace period, so when released users who purchased ECM during grace period will get the upgrade for free.

    About the ETA, I hope to get it released in 1-2 months at most, as it is actually a pretty big version.

    Best regards,
    Krull
     
    cursedtoast likes this.
  19. cursedtoast

    cursedtoast

    Joined:
    Apr 27, 2018
    Posts:
    62
    Thanks for letting us know. I'm personally happy to pay the difference for an upgrade if it means keeping your project afloat. This really is a great controller and I look forward to seeing the new version some day.
     
    Krull likes this.
  20. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    It seems slightly cynical to offer it on discount on the asset store for cyber week when it’s an semi abandoned product? I’m just saying that 17 euros is still quite a bit of money for a lot of people, knowing that this version won’t be updated, the next major update is at least a couple of months away and further updates will be paid. I assume the grace period won’t include cyber week sales?
     
  21. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    I think you are making some wrong assumptions or I did not make it clear, so le me clarify.

    1.- ECM has been in store for more than 4 years and is far from be an abandoned project, actually its more alive than ever.

    2.- The curren ECM version will not be abandoned or replaced, I will still support it, and make free updates for it, as always has been, however some new features will be only available in newest version, which I’ll refer for now as ECM 2, as I commented before it uses a different algorithm and those features are just not possible in current implementation.

    3.- The next ECM version its a completely new product, pretty much like a new Windows version, so users have a discounted upgrade option in case they decide to upgrade.

    4.- Current ECM users can decide if they want or not to upgrade to the new version (ECM 2) paying just the price difference between versions, so you are still taking advantage of the discounted price in case you decide to upgrade later, your upgrade price will be the difference as if you have paid the full ECM price, nothing cynical or sneaky here.

    5.- At this moment I just can no tell who will enter in grace period, as the product is not even finished, once it’s released will see.

    6.- I am very committed and serious with ECM and in offering the best support I can, so if you are not satisfied with ECM , please contact me to support email, I’ll offer you a full refund.

    -Krull
     
    Zebbi likes this.
  22. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    No worries, I've just seen other assets go on sale and then be deprecated in favor of a rewrite version. I also understand completely that a complete rewrite would be impossible to maintain as an update, and I certainly don't mind paying for a new product, I just feel that I've paid (albeit, a heavily discounted price) for a tool that I'm going to have to pay for again in a few months (again, at a discount).

    I appreciate the money-back guarantee, but as I've just bought ECM this week I still haven't had a good chance to enjoy working with it yet. I apologize if I sounded rude or contentious, I just wanted to clarify the situation; I meant it *seemed* cynical to *me* (as it has when I've encountered other asset depreciations after a sale) but clearly this isn't the case and I hope I really haven't come off as too entitled or expectant.
     
  23. anpShawn

    anpShawn

    Joined:
    Oct 1, 2012
    Posts:
    18
    I'm actually very glad to hear that ECM2 will be a new product, I'm assuming that means I can import it into my current project and run it side-by-side with ECM1 until I update my code. Unless ECM2 shares the exact same namespace?
     
  24. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    I understand it and don't worry, I myself as an asset store user have suffered the same issue with deprecated / abandoned projects, so I am aware of how awful it can be, but you can rest assured this is not the case with ECM.

    I just wanted to take the opportunity to make it clear about the new ECM version, and to avoid confusions about the ECM current and future state, as unfortunately abandoned projects are a real thing in the Asset Store.

    If have further questions abou it, please let me know it,
    Krull
     
    Zebbi likes this.
  25. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Yes, thats correct, the new ECM version is on its own namespace and both current ECM and ECM2 can exist on project at same time without issues.

    Regards,
    Krull
     
    cursedtoast likes this.
  26. cursedtoast

    cursedtoast

    Joined:
    Apr 27, 2018
    Posts:
    62
    Excellent. I've spent $70 on assets before and saw the deprecation notice a handful of months later.
    I'm really enjoying ECM and have had the thought cross my mind "this better not vanish overnight".

    If paying for a small upgrade helps keep you afloat and keeps the project going, I'm more than happy to. I really love what you have going with this project.
     
    Krull and Zebbi like this.
  27. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Thank you, I appreciate it! Glad to hear you like ECM!

    Definitely, you don't have to worry about ECM at all, as I commented I am very committed to it, and willing to improve it in the near future.

    Cheers,
    Krull
     
    Zebbi likes this.
  28. dmarqs

    dmarqs

    Joined:
    Oct 16, 2013
    Posts:
    41
    Hi,

    It's good to hear about ECM 2. =)

    It will include 'parkour' movement? Like wall-running, walking stair railing and stuff like that?
     
  29. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @dmarqs

    Well, yes and no :) not directly integrated into the BaseCharacterController, as my main goal with ECM and ECM2 is to a keep it as a clean, lean a feature reach character controller to serve as a base for your game mechanics.

    Having said that, I definitely have planned to include that kind of mechanics as examples, mechanics similar to those found on GhostRunner like wall grab and run, wall jump, railing, slides, dash, etc.

    Regards,
    Krull
     
  30. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    Hi @Krull , I tried setting up the character controller in such a way that it stands firmly on a rotating, non-kinematic rigidbody based platform. The rotational movement of the platform is ignored though, no matter what I do.
    Is there something I'm missing? Or is that unsupported?

    This is my platform setup:
    upload_2020-12-7_11-46-26.png
     
  31. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    I saw that 1.8 implemented Wall Jumps, but I don't see how to add this myself.

    *Edit* I just edited what I needed myself. I never needed a wall grab so I copied the Jump method and used ApplyImpulse to push me away and up from the wall.
     
    Last edited: Dec 8, 2020
    Krull likes this.
  32. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Gooren,

    About your question, yes by default an ECM character will only treat as platform a kinematic rigidbody, so in order to allow a non-kinematic rigidbody act as a platform, you'll need to modify the CharacterMovement component, specifically the DetectGround and SnapToPlatform methods in order to remove the kinematic check condition.

    Regards,
    Krull
     
    Gooren likes this.
  33. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    Thanks for info. Just one question - I suspect there is a reason for enabling non-kinematic rigidbody interaction to be a bit cumbersome instead of being a simple boolean inspector setting? Are there any major problems/drawbacks I can expect?
    Is it even reasonable to enable it?
    This Character Controller is non-kinematic, fully physics based, right? So it should work nicely?

    Regards,
    Stepan
     
  34. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Gooren,

    About your questions, by default is disabled mostly because internally an ECM character will treat other non-kinematic rigidbody as another character and will prevent to climb it, it was by initial design as persist to date as no many users have requested this behavior, while by other hand (once again) internally treat a kinematic rigidbody as a platform and will snap the character to it (movement and rotation).

    Having said that, users (who need it) have been able to modify it (as previously commented) to allow snap on dynamic rigidbodies and yes it work, however depending of your non-kinematic platform movement, could cause a little slippery movement, mostly because the rigidbody velocity retrieved during ground detection, is the physics last frame, and while ECM uses a post physics recovery (on its late fixed update coroutine), it's not 100% precise in this case.

    If you prefer to contact me through email, I can share with you the modified functions, the reason for this is because for sharing ECM code with you, I will require your invoice number.

    Best regards,
    Krull
     
  35. Iainduthie

    Iainduthie

    Joined:
    Oct 30, 2013
    Posts:
    5
    Hi i got this asset recently and really finding something difficult to do with this asset it could be me but how could you implement a toggle for the crouch and speed control attatched to the crouch state.
     
  36. YorkshirePudding

    YorkshirePudding

    Joined:
    Apr 10, 2013
    Posts:
    18
    Hi,

    This is not really an ECM question, more of a general programming question to be fair.

    With that said, I use crouch toggle for my player character I achieved it in the following manner.

    Code (CSharp):
    1.  
    2. protected override void HandleInput() {
    3.   // Other movement code here...
    4.  
    5.   // Crouch toggle
    6.   var crouchPressed = _playerInput.GetButtonDown(InputActions.Crouch.ToString());
    7.   crouch = crouchPressed ? !crouch : crouch;
    8. }
    I'm using Rewired for the input here, but you can see what the end goal is. Essentially, I check if the crouch button is pressed then use this as a trigger to flip the crouch flag. This code is a little rough as I'm still prototyping, but it gets the job done and should help push you in the right direction.

    EDIT: I'm not sure how your chosen input solution works, Rewired will only return true for GetButtonDown in the same frame the key is pressed. It is perfectly reasonable to assume that some solutions will return true every frame while it is held down, if that is the case then the flag will keep toggling. Just a heads up.
     
    Last edited: Dec 21, 2020
    Krull likes this.
  37. Iainduthie

    Iainduthie

    Joined:
    Oct 30, 2013
    Posts:
    5

    oh okay yeah i was thinking it was my fault not the assets thank you so much it really helps.

    looking at your code and the way you have done it i can see everything i was doing wrong.
     
  38. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Iainduthie,

    Yes as @YorkshirePudding kindly commented, you use the HandleInput to modify the default input functionality with the one your game requires, in your case toggle the crouch.

    While for the speed modification, I suggest handle it in a similar way but using the CalcDesiredVelocity method, this method is the responsible of feeding the character's desired velocity to the CharacterMovement Move method which in the end will perform the movement.

    The idea here, is modify the BaseCharacterController speed property depending of your Character's current state (eg: walking, running, crouched, etc), for example, in your custom controller:

    Code (csharp):
    1.  
    2. public class SpeedModController : BaseCharacterController
    3. {
    4.     [Space(15f)]
    5.     public float maxWalkSpeed;
    6.     public float maxWalkSpeedCrouched;
    7.  
    8.     /// <summary>
    9.     /// Returns the character's speed for its current state.
    10.     /// </summary>
    11.  
    12.     private float GetCharacterSpeed()
    13.     {
    14.         if (isCrouching)
    15.             return maxWalkSpeedCrouched;
    16.  
    17.         return maxWalkSpeed;
    18.     }
    19.  
    20.     protected override Vector3 CalcDesiredVelocity()
    21.     {
    22.         // Set this character speed for its current state
    23.  
    24.         speed = GetCharacterSpeed();
    25.  
    26.         // return desired velocity (basically moveDirection * speed)
    27.  
    28.         return base.CalcDesiredVelocity();
    29.     }
    30. }
    31.  
    Actually you can follow the same approach for states requiring different speeds. Additionally you can review the included examples (Examples folders) for working implementation of above method.

    Kind regards,
    Oscar
     
  39. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    How would I go about implementing a dodge move? Normally I used Root Motion to determine movement but I'm wanting to use physics based movements.
     
  40. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Shiro_Rin,

    As you commented the easiest way to do is with root motion, however if this is not an option or not desired, you can implement it similar to a jump, I mean an impulse in the desired dodge direction, however as character ground movement is affected by its ground settings (eg: groundFriction, deceleration, etc) you will need to modify those values when dodging and restore it when dodge state is completed.

    A simpler method is pause ground detection during your dodge duration, so it will bypass the ground friction, deceleration, etc, and allows dodge be the same on ground and in air as follows:

    Code (csharp):
    1. protected override void HandleInput()
    2. {
    3.     base.HandleInput();
    4.  
    5.     if (moveDirection.sqrMagnitude > 0 && Input.GetKeyDown(KeyCode.X))
    6.     {
    7.         // Apply dodge / dash impulse
    8.  
    9.         movement.velocity += moveDirection * 10f;
    10.  
    11.         // Disable grounding during dodge / dash duration
    12.  
    13.         movement.DisableGrounding(0.5f);
    14.        
    15.     }
    16. }
    Regards,
    Krull
     
    Pixelith likes this.
  41. Pixelith

    Pixelith

    Joined:
    Jun 24, 2014
    Posts:
    580
    Thanks! I didn't know DisableGrounding was a method, and that's perfect because I wanted the dash to work in air as well.
     
  42. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Excellent, glad I was able to help!

    Kind regards and Happy Holidays,
    Krull
     
    Pixelith likes this.
  43. Jairusx

    Jairusx

    Joined:
    Jun 25, 2020
    Posts:
    62
    Hello guys and happy new year!!!

    I want to start implementing sharp accent's climbing system to the controller
    Is this possible? Are both system compatible? Is it straight ahead just making new script extending the ECM script or I will need to modify the existing one?

    Here is the tutorial -


    Thanks in advace! :)
     
  44. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hello @Jairusx,

    Happy new year to you too!

    Well unfortunately I am really not familiar with it so at this moment I could not tell.

    However, I think it should be possible, after all to move an ECM character all you need is set its moveDirection property with your desired movement direction (in world space), be it form input, AI, etc.

    I'll review the climbing system and see how it could be combined with ECM.

    Regards,
    @Krull
     
  45. fecoramirez

    fecoramirez

    Joined:
    May 2, 2019
    Posts:
    2
    Hello @Krull. Happy New Year :)

    Sorry for bothering, I was looking for a solution but I think I need some help from someone who masters this.

    What I'm looking for is a way to toggle between both normal rotation and one based on camera look. Like when you grab your bow or pistol.

    Can you help me out?

    Thanks a lot.
     
  46. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Hi @fecoramirez

    Happy new year!

    About your question, you can use the UpdateRotation method in your custom controller, for example:

    Code (csharp):
    1.  
    2. public bool orientToMovement;
    3.  
    4. ...
    5.  
    6. if (orientToMovement) {
    7.   // Rotate towards movement direction (input)
    8.  
    9.   RotateTowardsMoveDirection();
    10. } else {
    11.   // Rotate towards camera view direction
    12.  
    13.   RotateTowards(Camera.main.transform.forward);
    14. }
    Then you use the orientToMovement to toggle bewteen normal rotation and camera rotation.

    Regards,
    Krull
     
  47. fecoramirez

    fecoramirez

    Joined:
    May 2, 2019
    Posts:
    2
    @Krull I seriously can't believe it was that easy! Your Character Controller really got us covered.

    Thank you a lot. Looking forward your next update!
     
    Krull likes this.
  48. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Awesome Work,
    We used this package in many games. It's Save our time.
     
    Krull likes this.
  49. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    Excellent! glad I was able to help you!
     
    fecoramirez likes this.
  50. Krull

    Krull

    Joined:
    Oct 31, 2014
    Posts:
    771
    @payalzariya07,

    Thank you, thats gereat!, happy to know you like ECM and helped with your games :D

    Regards,
    @Krull