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 amcneilly84 · Dec 22, 2012 at 07:44 PM · animationlocalworldsnap

Turn left animation. snaps back

When i play my "turn left" animation twice, the player snaps back to the start position at the start of the second animation.

The "turn left" animation rotates the player 90 degrees. I would expect that playing the "turn left" animation twice would cause the player to face the 180 degrees from the start point (facing opposite direction).

Why does the player snap back to the start position on the second play of the animation ? How can i fix this issue ? Is it possible to animation rotations to control the movement of the player or is Unity severely limited and i should look at a better 3d game engine, that is more capable ?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by youngapprentice · Dec 22, 2012 at 08:26 PM

Playing an animation twice will, simply, play it twice. Just the same, when you watch a movie of a character running across a screen, if you go back and watch it again, the character will always be at the same place at the same frame. An animation is just like a movie.

Why not alter the character's transform by using Transform.Rotate ?

This would allow you to create a speed variable and then you can alter how quickly the character turns, etc. I would recommend multiplying this speed variable by Time.deltaTime to make sure your transformation is independent of frame rate.

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 amcneilly84 · Dec 22, 2012 at 11:13 PM

The issues is that the player is a "aircraft" and the turn left is not a simple rotate 90 degrees. The animation is a series of turns to turn the player 90 degrees.

A solution i have developed that almost works is below. The script takes the animations from the child after the animation has completed and then puts those rotations in the parent and zeros the rotations of the child. This works because the next time the animation is called the child (that is animated) starts at absolute value of 0.

The problem is that that the player appears to do a jumo to a position. I am not sure if that is because two adjustments to rotations parent, child causes flicker. Does anyone know a better solution ?

    void LateUpdate()
     {
         if (!animation.isPlaying && wasPlaying)
         {
             //only swap transfroms if rotaions have changed
             if(animatedChildGameObject.transform.rotation != Quaternion.identity)
             {
                 Quaternion qVals = new Quaternion(Utility.GetAircraftRoot().transform.rotation.x,
                     Utility.GetAircraftRoot().transform.rotation.y,
                     Utility.GetAircraftRoot().transform.rotation.z,
                     Utility.GetAircraftRoot().transform.rotation.w);
                 
                 animatedChildGameObject.transform.rotation = Quaternion.identity;
                 parentGameObject.transform.rotation = qVals;
             
             }
         }
 
         wasPlaying = animation.isPlaying;
     }
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

10 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

Related Questions

Animation Keeps Playing In Global Coordinates 2 Answers

Vertices Array only given in local coords? 1 Answer

Can I make animations snap to a frame? 1 Answer

simple rotation question c# local/world 2 Answers

how to convert an objects local axis vector to 'world' vector. 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