Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by BimSekai · Oct 01, 2015 at 08:49 AM · animationanimatorblending

How to use two animations for a simple translation ?

Hello community ! I've been working on a simple task, yet I can't get it done :( I'm new to the whole animator and mechanim thing, and i apologise for mistake I may be about to say !

I have a simple component (let's say, a cube), on it i have an animator, with 2 animations named ZTranslation and XTranslation. The names are pretty explicit, it translates my cube from -1 to 1 on either X or Z axis. I have 2 Sliders, that must control the position of the cube on each axis, I can manage to link 1 axis on 1 slider, using:

 anim.SetFloat("XTranslation", newValue);

When the slider is moved, newValue being the value of the slider, and XTranslation being a parameter (float) of the same name as my animation. Then i use this code in Update():

 anim.Play("XTranslation", 0, anim.GetFloat("XTranslation"));

In order to place the cube at the right place and it works. However, the same code will NOT work with the Y axis as well since (i think) the cube is still affected by the older animation (the cube will NOT move, in any way when i move the slider).

If I move the animation blocks in each slider's linked method:

 public void NewValuePosZ(float newValue)
     {
         anim.SetFloat("ZTranslation", newValue);
         anim.Play("ZTranslation", 0, anim.GetFloat("ZTranslation"));
     }

The cube will move on each axis, but it will always come back to it's default position in the other axis (I think one animation is overwriting the other).

So here is my question: How do I mix those animations to cover the whole (-1,-1,0) -> (1,1,0) possibilities ? Is there a transition to set in the animator for this ? I've read people about Blending but i can't figure out how to set this up, since i don't have a skeleton on my cube (and is it the solution ?).

Thanks for reading,

JRS

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 BimSekai · Oct 01, 2015 at 11:18 AM

Nevermind, I found it at last, by default the new layer have a weight of 0.... Changed the weight, set each layer as aditive and it worked like a charm.

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

37 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 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 set position to frame with c# script ? 1 Answer

Broken animations in Unity 5.3.5f 1 Answer

Placing my own animation idle&move to player 0 Answers

How can I tell if an animation can be used by animator? And how to create this kind of animation 1 Answer

Attach gun to two hands 0 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