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 waleeds37 · May 28, 2015 at 06:32 AM · animationjavascriptanimatorcrossfadeblend

How to play multiple animations on the same game object.

I am creating a 3d endless runner game. Currently my game object contains two further child (Rider and the horse). The component (Animation)is attached to rider only and in the animator component play automatic is enabled. Now the problem is that its default animation is "horse_galloping" which is working fine. whenever i press "space" key jump animation plays once but the previous animation "horse_galloping" stops working, although the loop is enabled but still its not working after hitting space key. What i want is to keep playing animation "horse_galloping" after the "horse_jump" animation is played. Following is my code::

private Animation anim;

void start() { anim = mygamebobject.GetComponent ();

}

update ()

{

if (Input.GetKeyDown ("space"))

{

anim.CrossFade("horse_jump"); }

}

Comment
Add comment · Show 2
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 waleeds37 · May 27, 2015 at 07:33 AM 0
Share

Animation component is attached to the gameobject (Rider). Parent GameObject is (HorseRider).

avatar image Hellium · May 28, 2015 at 08:54 AM 0
Share

Have you read the documentation about the CrossFade function ?

http://docs.unity3d.com/ScriptReference/Animation.CrossFade.html

Fades the animation with name animation in over a period of time seconds and fades other animations out.

2 Replies

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

Answer by redeemer · May 28, 2015 at 12:38 PM

My first recommendation would be for you to change to Mecanim animation if possible. But if you intend to use Legacy I think this would help you : http://docs.unity3d.com/Manual/AnimationScripting.html

You can "play" with the weight of the animations. That means, an animation with higher weight would not be "cut" by an animation with a lower one. You just have to set the weight of your jump animation higher than the galloping animation and then, the galloping won't crossfade until the jump animation is over.

Hope I made my point, I've an example code but can't get to it right now. If you need it tell me and I'll post it when I get home.

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
avatar image
0

Answer by PORUSH UNITY · May 29, 2015 at 08:00 AM

try to connect horse_galloping animation to horse_jump in animator window.so it come back to horse_galloping animation after the horse_jump animation complete.

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 redeemer · May 29, 2015 at 10:24 AM 0
Share

I think he's using Lagacy (there is no animator), so he has to control the animation through code

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Animator.CrossFade or Animator.CrossFadeInInFixedTime does not play animation after crossfading. 0 Answers

How can I smoothly transition my player camera from manual control into an animation? 1 Answer

Animation.Blend with Animator? 0 Answers

what is difference of animation blend and animation crossfade? 0 Answers

How to Loop a Animator Controller Component using wrapMode PingPong 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