Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Twinklier · Jul 22, 2018 at 11:23 AM · character controllerspeed issues

Character Controller moves slow?

Player walks so slow, sometimes doesn't even walk. Jump is impossible. Altering speed doesn't do anything. Help ;(

 void Start () {
         characterController = GetComponent<CharacterController>();
     }
     
     void Update () {
         transform.eulerAngles = Vector3.zero + (Vector3.up * camRotY);
 
         {
             moveDir = new Vector3(Input.GetAxis("Horizontal"), verticality, Input.GetAxis("Vertical"));
             moveDir = transform.TransformDirection(moveDir);
             characterController.Move(moveDir * Time.deltaTime);
             moveDir *= speed;
 
             if (!characterController.isGrounded)
             {
                 if (verticality < 0)
                     verticality *= 1.01f;
                 verticality -= Time.deltaTime * 6;
                 camera_wobble.cullingMode = AnimatorCullingMode.CullCompletely;
             }
             if (characterController.isGrounded)
             {
                 if (Input.GetAxis("Jump") != 0 && slope_angle < characterController.slopeLimit)
                     verticality = 1.8f;
                 verticality = 0;
 
                 //cam wobble, no movements here
                 {
                     if (moveDir != Vector3.zero + (moveDir.y * Vector3.up) && slope_angle < characterController.slopeLimit)
                         camera_wobble.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                     else
                     {
                         camera_wobble.cullingMode = AnimatorCullingMode.CullCompletely;
                         Camera.localPosition =
                             new Vector3(Mathf.Lerp(Camera.localPosition.x, 0, Camera.localPosition.x * 0.2f),
                             Mathf.Lerp(Camera.localPosition.y, 0, Camera.localPosition.y * 0.2f),
                             Mathf.Lerp(Camera.localPosition.z, 0, Camera.localPosition.z * 0.2f));
                     }
                 }
             }
         }
 
         //cam rot, no movements here
         {
             camRotX -= Input.GetAxis("Mouse Y") * sensitivity * 0.8f;
             camRotY += Input.GetAxis("Mouse X") * sensitivity;
             camRotX = Mathf.Clamp(camRotX, -90, 90);
             Camera.eulerAngles = new Vector3(camRotX, camRotY, 0);
         }
     }
     void OnControllerColliderHit(ControllerColliderHit hit)
     {
         slope_angle = Vector3.Angle(Vector3.up, hit.normal);
     }
 }
 

I was trying to make the player moves horizontally slower while in air, so I put the moveDir *= speed into the .isGrounded and ! .isGrounded brackets and adjust each from there. That's when the problem occur. I move it back to where it was and the problem isn't gone.

Help? Please ; (alt text

have-a-look.png (19.1 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tormentoarmagedoom · Jul 23, 2018 at 08:01 AM 0
Share

Good day.

Look at this part of code:

          characterController.$$anonymous$$ove(moveDir * Time.deltaTime);
          moveDir *= speed;

Yopu first move the player, and then apply the speed.... of course changing speed does nothing... you are pplying the speed after moving... each frame..

Change the order of that 2 lines.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

147 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Character Cannot Move from its Spot 0 Answers

Switching platforms causes so many errors why? 0 Answers

How would i clamp X and Z without clamping Y? 1 Answer

I'm having issues making my Character Controller for my FPS.,I'm having issues with my Character Controller, and i'm not sure how to fix it. 0 Answers

Character controller gets stuck on ledges? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges