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 raptorkwok · Feb 13, 2014 at 04:20 AM · character animation

Character Position Moved after Animation assigned

My character position is moved after an animation is assigned.

The character GameObject is assigned with Animation, RigidBody, Capsule Collider and a C# Script Component.

The C# Script (animation part) is as follow:

 public class MyCharacter : MonoBehaviour {
         // Animations
     public AnimationClip idleAnimation;
     public AnimationClip slideAnimation;
     public AnimationClip runAnimation;
     public AnimationClip jumpPoseAnimation;
     private Animation charAnimation;
     
     enum CharacterState {
         Idle = 0,
         Running = 1,
         Sliding = 2,
         Jumping = 3,
     }
     
     private CharacterState charState;
 
     void Start () {
         charState = CharacterState.Running;
         charAnimation = gameObject.GetComponent<Animation>();
         if(!charAnimation) {
             Debug.Log("No Animation Component.");
         } else {
             AnimationEvent syncRunEvent = new AnimationEvent();
             syncRunEvent.time = runAnimation.length;
             syncRunEvent.functionName = "SyncRunAnimation";
             runAnimation.AddEvent(syncRunEvent);
         }
     }
 
         void Update () {
                 // Animations
         if(charAnimation) {
             if(charState == CharacterState.Jumping) {
                 charAnimation.CrossFade(jumpPoseAnimation.name);
             } else if(charState == CharacterState.Sliding) {
                 charAnimation.CrossFade(slideAnimation.name);
             } else {
                 charAnimation.CrossFade(runAnimation.name);
             }
         }
     }
 
         void SyncRunAnimation() {
         Debug.Log("Sync Run");
         transform.position += new Vector3(0, 3, 0);
     }
 }

Before assigning the animation, the character is standing in the ground at position (0, 0.6, 0). After assigning, the character submerges INTO the ground, stuck; position changed to (0, -0.75, -0.55). How can I control the animation position ?

Note: I tried to use SyncEvent to move up ( increase Y axis ), but it does NO effect at all.


UPDATE This only happens when Animation is set to Legacy. If I set the animation to Generic, it has no problem, but Console issues errors :

The AnimationClip 'run' used by the Animation component 'MyCharacter' must be marked as Legacy.

and the animation could not be played. How can I make it work with Generic animation / correct position with Legacy animation ?


UPDATE 2 Here is a simplified version of the scene, WITHOUT any script.

Before I hit the "PLAY" button Before hit Play

After I hit the "PLAY" button After hit Play

So the problem is not related to codes, right ?

screen shot 2014-02-17 at 11.01.49 am.png (88.2 kB)
screen shot 2014-02-17 at 11.02.13 am.png (65.4 kB)
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 whydoidoit · Feb 13, 2014 at 04:21 AM 0
Share

Sounds like it might be a scaling issue between the model scale and the scale of the animation - that often has that effect for me.

avatar image raptorkwok · Feb 17, 2014 at 03:07 AM 0
Share

just updated the question with screenshot. How can I check if it is a "scaling" issue ?

1 Reply

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

Answer by raptorkwok · Feb 17, 2014 at 06:34 AM

To solve this issue, I removed the Position keyframes in Animation panel in Unity 3D.

Remove Properties


screen shot 2014-02-17 at 2.30.48 pm.png (30.9 kB)
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

18 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

Related Questions

How can I use a joystick for a mobile app to control specific limbs of a character? 0 Answers

What's the best way of setting up a FPS character? 1 Answer

my prolem with Unity Humanoid joint articulation 0 Answers

Does Unity support FBX files directly from MotionBuilder? 0 Answers

2D physics animation. How do I animate a character with physics 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