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 /
avatar image
1
Question by QuincyOnIce · Jan 01, 2020 at 12:10 AM · charactercontrollercharacter controllercharacter movementdash

Character Controller based 'dash' function moves strangely in one direction, despite values seemingly being correct.

Hello, I'm working on a pretty simple dash function for my character controller. But there's a weird problem.

alt text

alt text

In the first picture, the yellow arrow represents actual movement while the green one represents what I want and expect it to do. As you can see, it moves diagonally instead of straight. In the second, it moves exactly as I want it to, In a straight line backwards, as represented by the green arrow.

 private void Dash(Vector3 Direction)
     {
         GameObject WarpClone = Instantiate(gameObject);
         WarpClone.transform.position = transform.position;
         Destroy(WarpClone.GetComponent<CharacterMovement>());
         Destroy(WarpClone.GetComponent<CharacterController>());
         Destroy(WarpClone.GetComponent<Animator>());
         foreach (Transform child in WarpClone.GetComponentsInChildren<Transform>())
         {
             Destroy(child.GetComponent<Collider>());
             SkinnedMeshRenderer[] SMRs = WarpClone.GetComponentsInChildren<SkinnedMeshRenderer>();
             MeshRenderer[] MRs = WarpClone.GetComponentsInChildren<MeshRenderer>();
             foreach (SkinnedMeshRenderer SMR in SMRs)
             {
                 SMR.material = warpMaterial;
             }
             foreach (MeshRenderer MR in MRs)
             {
                 MR.material = warpMaterial;
             }
         }
         Destroy(WarpClone, 100f);
         CC.Move(Direction * dashStrength);

Here's the code for actually moving and creating the 'silhouettes'.

 private void DashFuncW()
     {
         if (Time.realtimeSinceStartup - timeOfFirstButton < DoublePressSpan && Input.GetKeyDown(KeyCode.W) && firstButtonPressed)
         {
             Dash(transform.forward);
 
             firstButtonPressed = false;
             timeOfFirstButton = 0f;
         }
         if (Input.GetKeyDown(KeyCode.W))
        {
             timeOfFirstButton = Time.realtimeSinceStartup;
             firstButtonPressed = true;
        }
     }

 private void DashFuncS()
     {
             {
                 if (Time.realtimeSinceStartup - timeOfFirstButton < DoublePressSpan && Input.GetKeyDown(KeyCode.S) && firstButtonPressed)
                 {
                     Dash(-transform.forward);
         
                     firstButtonPressed = false;
                     timeOfFirstButton = 0f;
                 }
                 if (Input.GetKeyDown(KeyCode.S))
                 {
                     timeOfFirstButton = Time.realtimeSinceStartup;
                     firstButtonPressed = true;
                 }
     }

And here's the code to get the double tap input.

I really can't figure out why it behaves like this; since the backwards one works fine but the front one doesn't, even though they use practically the same values. Any help at all would be appreciated.

Comment
Add comment
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

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

132 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

Related Questions

Can I Change Expression Of Player While Running, Getting Hurt Or Dead, Or Jumping, Idle, Walking, Or Sneaking 2 Answers

I need to know how to apply force to an object when using a character controller and I'm not that good at coding either any answers will be greatly appreciated. 0 Answers

Player acts weirdly when I release movement input 0 Answers

CharecterController.Move() ignores parents movement 0 Answers

My player is stuck on left and right side(Endless Runner) 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