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 tredpro · Nov 29, 2013 at 07:09 AM · vuforiaaugmented realityimage target

animated a model with a button in Unity with vuforia

I am working with unity and vuforia and what i am wanting to do is have the image target render my 3d model and a visual button. the model will be animated. I need the button to start a new animation for the 3d model when pressed but as soon as the animation finishes it needs to go back to the original animation. Please help me find the correct way to do this.

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 Spinnernicholas · Nov 29, 2013 at 07:44 AM

For full answer, goto forum HERE.

[OLD] Using the animation component, you can have the button event call animation.Play("animation name");.

When the animation is over, animation.isPlaying = false;.

 void Update()
 {
   if(!animation.isPlaying)
   {
     animation.Play("default animation");
   }
 }


Comment
Add comment · Show 24 · 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 tredpro · Nov 29, 2013 at 07:47 AM 0
Share

so at the end it will go back to original animation? and i want a different obj to control the animated model's animations

avatar image tredpro · Nov 29, 2013 at 07:47 AM 0
Share

so at the end it will go back to original animation? and i want a different obj to control the animated model's animations

avatar image Spinnernicholas · Nov 29, 2013 at 09:40 PM 0
Share

Add this script to the same gameobject that has the animation component. It will do nothing until you call PreviewAnimation("defaultAnim", "previewAnim");. it will then activate itself and play the desired animation once before returning it to the default animation and deactivating itself.

 class PreviewAnimation:$$anonymous$$onoBehavior
 {
 
 string origionalAnimation;
 Wrap$$anonymous$$ode wrap$$anonymous$$ode;
 
 void Awake()
 {
 //disable script
   enabled = false;
 }
 
 public void PreviewAnimation(string origionalAnimation, string animation)
 {
 //enable script
   enabled = true;
 //Save Animation Settings
   this.origionalAnimation = origionalAnimation;
   wrap$$anonymous$$ode = this.animation.wrap$$anonymous$$ode;
 //Play animation once
   this.animation.wrap$$anonymous$$ode = Wrap$$anonymous$$ode.Once;
   this.animation.Play(animation);
 }
 
 void Update()
 {
   if(!animation.isPlaying)
   {
 //Restore Animation Settings
     animation.wrap$$anonymous$$ode = wrap$$anonymous$$ode;
     animation.Play(origionalAnimation);
 //disable script
     enabled = false;
 
   }
 }
 
 }
avatar image tredpro · Nov 29, 2013 at 10:41 PM 0
Share

so you took all the hard work out of this for me? thanks

avatar image tredpro · Nov 29, 2013 at 11:52 PM 0
Share

I am getting this error The type or namespace name `String' could not be found. Are you missing a using directive or an assembly reference? for 3 locations

Show more comments

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

17 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

Related Questions

A node in a childnode? 1 Answer

keep instance of that 3d model after removing image target 0 Answers

Anyone know how?.......when ImageTarget rotation is 90 degree ..... display another sprite image 0 Answers

Unvalid import settings when converting image to an image target in Unity 5.5.1f1 Personal (64bit) with Vuforia 6.2 SDK 0 Answers

Heating Issue in AR android app 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