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
1
Question by s_aint47 · May 09, 2012 at 07:02 PM · animationwaitforseconds

Animation there but not playing?

I have this code here:

 private var right_left_1=false;
 private var back_front_1=false;
 private var back_front_2=false;
 private var screenCenter = new Vector3(0.5F, 0.5F, 0);
 private var hit : RaycastHit;
 
 function Update () {
 
 var ray = Camera.main.ViewportPointToRay(screenCenter);
 
 //right left 1
 
 if(Input.GetButton("Fire1")&& right_left_1==false){
   if (Physics.Raycast (ray, hit, 1000)) {
     if(hit.transform.tag=="BlueRightLeft1"){
        rl1();      
     }
   }
 }
 
 //back front 1
 
 if(Input.GetButton("Fire1")&& back_front_1==false){
   if (Physics.Raycast (ray, hit, 1000)) {
     if(hit.transform.tag=="BlueBackFront1"){
        bf1();       
     }
   }
 }
 
 //back front 2
 
 if(Input.GetButton("Fire1")&& back_front_2==false){
   if (Physics.Raycast (ray, hit, 1000)) {
     if(hit.transform.tag=="BlueBackFront2"){
        bf2();      
     }
   }
 }
 
 }
 function rl1(){
        hit.transform.animation.Blend("BlueRightLeftOut1");
        right_left_1=true;
        yield WaitForSeconds(5);
        hit.transform.animation.Blend("BlueRightLeftIn1");
        yield WaitForSeconds(1);
        right_left_1=false;
 }
 function bf1(){
        hit.transform.animation.Blend("BlueBackFrontOut1");
        back_front_1=true;
        yield WaitForSeconds(5);
        hit.transform.animation.Play("BlueBackFrontIn1");
        yield WaitForSeconds(1);
        back_front_1=false;      
 }
 
 function bf2(){
        hit.transform.animation.Blend("BlueBackFrontOut2");
        back_front_2=true;
        yield WaitForSeconds(5);
        hit.transform.animation.Blend("BlueBackFrontIn2");
        yield WaitForSeconds(1);
        back_front_2=false;   
 }

The animations that seem to play are the last block moved. I tried moving them individually ant they work.

The error code:

The animation state BlueRightLeftIn1 could not be played because it couldn't be found! Please attach an animation clip with the name 'BlueRightLeftIn1' or call this function only for existing animations. UnityEngine.Animation:Blend(String) $:MoveNext() (at Assets/Scripts/MoveBlues.js:116)

Comment
Add comment · Show 5
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 bompi88 · May 09, 2012 at 08:09 PM 1
Share

The object the raycast is hitting has all animations attached to it? In animation settings on your object you can add animations and name them.

avatar image s_aint47 · May 10, 2012 at 04:00 PM 0
Share

animations are added in animation panel...they also work, i've tested them individually. When i try to play them all toghether they wont work.... the "BlueXXXXXIn" animations, the others work

avatar image bompi88 · May 10, 2012 at 04:10 PM 1
Share

What kind of wrap mode does these animations have?

avatar image s_aint47 · May 10, 2012 at 06:13 PM 0
Share

not really sure...i didn't put that in code but it should be start finish from 0 to 2 sec( animations are done with unity)

avatar image s_aint47 · May 12, 2012 at 03:08 PM 1
Share

Solved(sort of) insted of putting 2 animations to play i used one big one with an animated pause.

function bf2(){ hit.transform.animation.Blend("BlueBackFrontOut2");//longer animation back_front_2=true; yield WaitForSeconds(8); back_front_2=false;
}

1 Reply

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

Answer by bompi88 · May 10, 2012 at 10:11 PM

Are you sure you have set up your gameObject/Prefab as on this image? Where you should have all of your animations, like for example: BlueRightLeftOut1, BlueRightLeftIn1 etc. ( This i not an answer, but I need to show an image.)

alt text


Screen Shot 2012-05-11 at 00.05.39.png (33.9 kB)
Comment
Add comment · Show 1 · 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
avatar image s_aint47 · May 12, 2012 at 02:22 PM 0
Share

yes i did...as i said animation work but not all together

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation Window Time Unit 2 Answers

How do I make the animation play once then change scene? 0 Answers

Gun script help 1 Answer

Loop animation with a wait in between 3 Answers

Can the animation editor create local rotational data? 3 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