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 /
avatar image
0
Question by ThumbStorm · Jan 13, 2011 at 03:55 AM · animationwebplayerkeypresskeys

animations not working correctly in build

Hello,

I have a character on a bike that animates left and right into a lean position depending on which arrow key you hit. The animations were baked in from 3d max and are set to *clamp forever*. Everything works perfectly in the editor but when I build it to a web player it sometimes won't play the animation when I'm pressing the Up Arrow(accelerate) and the Left/Right Arrow(lean) at the same time, but does play it when only the Left/Right Arrow is pressed. I've tried about everything I can think of so any ideas would be great.

Here's the code :

var minAngle = 0.0; var maxAngle = 10.0; var toLeft : Transform;//bike lean left// var toRight : Transform;//bike lean right// var toCenter : Transform;//bike lean center// var speed = 4;//speed of lean// var returnCenter : boolean = false;//tells script it's ok to center bike// var bikeObject : GameObject; static var goRace : boolean = false; var Biker : GameObject; static var leftLean : boolean = false; static var rightLean : boolean = false;

function Awake() { goRace = false; leftLean = false; rightLean = false; }

function Update () { if (goRace) { //when game is ready this is set to true//

 if (Input.GetKey("left")) {
         returnCenter = false;
         transform.rotation = Quaternion.Slerp (transform.rotation, toLeft.rotation, Time.deltaTime * speed);
         Biker.animation.CrossFade ("LeanLeftB");
         leftLean = true;
         rightLean = false;

     } else {
         if (Input.GetKey ("right")) {
             returnCenter = false;
             transform.rotation = Quaternion.Slerp (transform.rotation, toRight.rotation, Time.deltaTime * speed);
             Biker.animation.CrossFade ("LeanRightB");
             leftLean = false;
             rightLean = true;

         }
     }
     if (Input.GetKeyUp ("left")) {
         leftLean = true;
         returnCenter = true;
         Biker.animation.CrossFade ("LeanLeftBackB");

     } else {
         if (Input.GetKeyUp ("right")) {
             rightLean = true;
             returnCenter = true;
             Biker.animation.CrossFade ("LeanRightBackB");

         }
     }
 if (Input.GetKey("left") && Input.GetKey("up")) {
         returnCenter = false;
         transform.rotation = Quaternion.Slerp (transform.rotation, toLeft.rotation, Time.deltaTime * speed);
         Biker.animation.CrossFade ("LeanLeftB");
         leftLean = true;
         rightLean = false;

     } else {
         if (Input.GetKey ("right") && Input.GetKey("up")) {
             returnCenter = false;
             transform.rotation = Quaternion.Slerp (transform.rotation, toRight.rotation, Time.deltaTime * speed);
             Biker.animation.CrossFade ("LeanRightB");
             leftLean = false;
             rightLean = true;

         }
     }   


     if (returnCenter) {
         transform.rotation = Quaternion.Slerp (transform.rotation, toCenter.rotation, Time.deltaTime * speed);

         if (leftLean){
             leftLean = false;
             Biker.animation.CrossFade ("LeanLeftBackB");
         }
         if (rightLean){
             rightLean = false;
             Biker.animation.CrossFade ("LeanRightBackB");
         }
     }
 //Debug.Log(transform.rotation);
 }

}

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ThumbStorm · Jan 14, 2011 at 04:35 AM

After cursing over and over and truing everything under the sun it turns out all I had to do is add add the fade length in the CroosFade ex. OLD - Biker.animation.CrossFade ("LeanLeftB"); NEW - Biker.animation.CrossFade ("LeanLeftB", .3);

That was a day and a half I'll never get back. Hope this helps anyone else who has the same problem.

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

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

No one has followed this question yet.

Related Questions

I'm having animation problems 0 Answers

How to select an animation clip by index number? 7 Answers

Play animation when 2 keys pressed? 3 Answers

Possibility of adding animation files during runtime? 1 Answer

Open Door on Keypress Not Working - Animations 1 Answer


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