Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed May 19, 2013 at 09:52 PM by KMKxJOEY1 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KMKxJOEY1 · May 07, 2013 at 09:29 PM · runrunninglocomotionsprintsprinting

What's wrong with my sprinting logic?

it seems like my 'down' boolean isn't updating, any help plz?

Here is my code:

     public void sprintManager()
     {
         if(needsSprint)
         {
             if(down)
             {
                 CurrentWeapon.WeaponTransform.animation[CurrentWeapon.sprintLoopAnim].speed = 0.5f;
                 CurrentWeapon.WeaponTransform.animation.CrossFade(CurrentWeapon.sprintLoopAnim,0.2f);
             }
             else
                 down_to_sprint();
         }
         else
         {
             up_from_sprint();    
         }
     }
     
     void down_to_sprint()
     {
         CurrentWeapon.WeaponTransform.animation[CurrentWeapon.sprintInAnim].speed = 0.5f;
         CurrentWeapon.WeaponTransform.animation.CrossFade(CurrentWeapon.sprintInAnim,0.2f);
         if(animation_finished(CurrentWeapon.WeaponTransform.animation[CurrentWeapon.sprintInAnim].name))
             down = true;
     }
     
     void up_from_sprint()
     {
         if(down)
         {
             CurrentWeapon.WeaponTransform.animation[CurrentWeapon.sprintOutAnim].speed = 0.5f;
             CurrentWeapon.WeaponTransform.animation.CrossFade(CurrentWeapon.sprintOutAnim,0.2f);
             if(animation_finished(CurrentWeapon.WeaponTransform.animation[CurrentWeapon.sprintOutAnim].name))
             {
                 down = false;
                 force_idle();
             }
         }
     }
     
     public bool animation_finished(string anim)
     {
         if(CurrentWeapon.WeaponTransform.animation.IsPlaying(anim) || CurrentWeapon.WeaponTransform.animation[anim].normalizedTime >= 1 )
             return true;
         else
             return false;
     }
Comment
Add comment · Show 3
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 ThunderEyed · May 07, 2013 at 09:40 PM 0
Share

Could you post something about how needSprint is toggled and how these booleans are initialized? NeedSprint =true if something is pressed? Down is default true or false?

avatar image KMKxJOEY1 · May 07, 2013 at 10:37 PM 0
Share

down is default false and needSprint is toggled by the player speed, but here is the code if you would like to take a look:

     //walking
             if(walkingstate == WalkingState.Running)
             {
                 needsSprint = true;
                 if(down)
                     down = false;
             }
             else if(walkingstate == WalkingState.Walking)
             {
                 WalkAnimationHolder.animation["walking"].speed = Velocity$$anonymous$$agnitude / walkSpeed;
                 WalkAnimationHolder.animation.CrossFade("walking", 0.2f);
                 WalkAnimationHolder.transform.rotation = WalkAnimationHolder.transform.parent.rotation;
                 
                 needsSprint = false;
             }
             else
             {
                 needsSprint = false;
 
                 if(!isAi$$anonymous$$g)
                 {
                     WalkAnimationHolder.animation.CrossFade("spreader_idle", 0.2f);
                     WalkAnimationHolder.transform.rotation = WalkAnimationHolder.transform.parent.rotation;
                 }
                 else
                 {
                     WalkAnimationHolder.animation.Rewind();
                     ADSHolder.localPosition = Vector3.Lerp(ADSHolder.localPosition, CurrentWeapon.Scopes[CurrentWeapon.CurrentScope].ADSPos, 1f);    
                 }
             }
avatar image KMKxJOEY1 · May 13, 2013 at 09:39 PM 0
Share

bumpp, :)

1 Reply

  • Sort: 
avatar image
0

Answer by KMKxJOEY1 · May 19, 2013 at 09:52 PM

fixed on my own

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

Follow this Question

Answers Answers and Comments

13 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

Related Questions

How to disable sprinting when slider reaches zero. 1 Answer

Can someone help me add running to my script? 1 Answer

Sprinting Script Issue 1 Answer

Character Jumping while Sprinting Code? 1 Answer

Mid air "sprint" 2 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