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 Rgalaxy · Jan 14, 2014 at 08:38 AM · animationjavascripttutorialsimple

Simple Animation for Unity3d

Hello Uniters !

I want to ask is there any simple way to just play an animation?

i've watching this Unity3d Video Tutorial about animation.. and it's so great i could really do anything about that.. But, it's too much to do.. i mean, is there any other way to play an animation beside this way? (simpler way)

i've been searching how to play animation, some ppl put out that i should place animation.Play("NameOfAnimation"); on function Update(); but after i attach the script to my character, it wont play that animation at all.. so i really want to know is there any easier way to do this? maybe by only call the name of animation on script, and the object will do it.. or something like that?

i know it's been so may ppl ask about this, but everytime i seach the Answer section, the code just not complete, that my character still not moving..

EDITED and also, when i select my object, there is no "Animation" tab on the Inspector of my object.. why does this happen? and how to make the tab show up on Inspector?

*sorry for bad english.

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 Quillicit · Jan 14, 2014 at 08:43 AM 0
Share

When you put code in Update(), it gets executed once every frame. Putting your animation in there will make it constantly restart, appearing as if it's not working at all.

Is this animation supposed to be happening all the time, or should it be triggered by a specific event?

avatar image Rgalaxy · Jan 14, 2014 at 08:44 AM 0
Share

it should loop the animation overtime, because it's like walking animation, and i only create 2 step of walking animation..

avatar image Quillicit · Jan 14, 2014 at 08:49 AM 0
Share

If it should only happen when you're walking, it would make sense to put it in your movement script. If you don't have an animation component, drag the animation onto the object.

avatar image Quillicit · Jan 14, 2014 at 08:51 AM 0
Share

Have a look at the animation portion of the Unity User $$anonymous$$anual, found here.

avatar image Rgalaxy · Jan 14, 2014 at 09:51 AM 0
Share

yeah, i see that $$anonymous$$ecanim work so great for animation on Unity, but if i want to evade that way, is there any easier way? because i don't really understand how to do it...

in $$anonymous$$ecanim it shows, we should import a .fbx file for every movement? isn't that too large?

and how to do it by script? i mean, do i still need to import walk,idle,jump of fbx animation to Unity to able to play the animation by script?

*sorry i know my question is a bit confusing.. i dont know how to tell this on the exact problem i have..

1 Reply

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

Answer by GameVortex · Jan 14, 2014 at 08:52 AM

The absolutely simplest way I can think of to play an animation would be:

  1. Add your model to the scene as a GameObject.

  2. Add an Animation component to the model.

  3. Add the animation clip you want to play to the Animation components "Animations" list.

  4. Also add the same clip to the "Animation" slot at the top of the Animation component.

  5. Make sure "Play Automatically" is checked.

  6. Press Play.

The animation should now play when you enter play mode.

This is the legacy system so you also have to make sure your model and animation is marked as legacy in the import settings.

Comment
Add comment · Show 5 · 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 Rgalaxy · Jan 14, 2014 at 09:07 AM 0
Share

wow, thank you very much @GameVortex it's happening ! yeah it could loop now.. but the problem is, how do i play this only when i need it? i mean, the first, object is just idle, but when i press this button, then play this animation? do i need to access the Animation and change the name of Animation?

avatar image HappyMoo · Jan 14, 2014 at 09:25 AM 0
Share

Now that you know the easy way, you accept the answer, then you're patient and go and learn the right way: http://unity3d.com/learn/tutorials/projects/s$$anonymous$$lth

:D

avatar image GameVortex · Jan 14, 2014 at 09:30 AM 1
Share

You do not need to change any name or change the Animation in the top slot. The Animation component has the ability to play any animation in the "Animations" list. So add all animations you want to be able to play on the model to the "Animations" list.

Here is an example script to play animation on a button click.

 public class PlayAnimationOnButtonClick : $$anonymous$$onoBehaviour
 {
     public AnimationClip clip;
     
     private void OnGUI()
     {
         if(GUILayout.Button("Play"))
         {
              animation.Play(clip.Name);
         }
     }
 }

Attach this to the same GameObject as the Animation is on. Then add the clip you want to be played to the "Clip" variable of the script. You can easily expand from this.

I would now recommend you to start going through Unity and scripting tutorials to learn Unity properly as @Happy$$anonymous$$oo suggested.

avatar image Rgalaxy · Jan 14, 2014 at 09:52 AM 0
Share

thanks @Happy$$anonymous$$oo and @GameVortex :)

So, i still need to import the .fbx file of every "clip" of animation? because, as far as i know, i still need the fbx to show the movement of any animation.. so do i need to import idle,jump,walk fbx of the object?

avatar image GameVortex · Jan 14, 2014 at 10:12 AM 1
Share

There are multiple ways of importing animations. Now would be the time to start going through tutorials and read up on the Unity $$anonymous$$anual. It is all explained there: **AnimationImport**.

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

22 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

Related Questions

How to create a sample Animation Blend test script? 0 Answers

Animation doesn't work 1 Answer

Using animations in prefabs 1 Answer

how to manage fbx files animation (blender) in unity using favascript 0 Answers

How do I animate a 2D sprite? 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