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
1
Question by vovo801 · Mar 18, 2015 at 02:56 PM · animation2danimatorcontrollergravity

Problem with character movement 2d when attaching animator

I made a character using spritesheet animation concept, than decision was made to switch to animating character using separate body parts like in this tutorial: Bone-Based Unity 2D Animation: Introduction

The character made using spritesheet animation is working perfectly fine. But with the new character i am encountering strange problems. I am trying to move both characters with the same script and attaching the same components to them:

  1. Circular colliders at feet, some other collider on top.

  2. Both have Rigidbody2d component attached to them. Fixed Angle is checked, Is Kinematic is unchecked.

  3. The same script to control movement is attached to both characters.

  4. Two different animator components because of different nature of the animation. In the first case animation was made manually in photoshop as a spritesheet. In second case, there was a file with body parts, and annimation was made in unity using mecanim.

The initial conditions are: the character is placed a little above the platform, so when the game starts, it should first fall and touch the ground, then walk on the platform.

I encounter following problems with character made with body parts:

  1. When Animator component is not attached or disabled, character is moving correctly, falling to the ground correctly, as determined by Rigidbody2d component. But of course no animation is happening.

  2. When I enable Animator component with the controller and all the animations i made using mecanim, character stays in mid air, and does not move anywhere, does not respond to controls, but flipping the character works, and proper animations show when trying to walk to one direction or another, but there is no actual movement. Update mode on the animator is set to Normal, Apply Root motion is unchecked, but checking it does not make any difference. Culling mode is Always Animate. The same settings work with the first character.

  3. When Setting update mode to Animate Physics, the Character start to jiggle heavily. It is also now trying to fall to the ground, but after lowering a little bit, returns to its initial position above the platform.

I tried using following code to move the character (both variations work on the first character (one that uses spritesheets)):

 rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);

Or

 transform.position += transform.right * move * maxSpeed * Time.deltaTime;

I feel like I am missing something out, or did something wrong with animations on the second character. Any ideas?

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 vovo801 · Mar 18, 2015 at 02:11 PM 0
Share

I have found a similar question here: http://answers.unity3d.com/questions/648238/2d-animator-component-makes-my-player-stuck-in-spa.html

It says checking or unchecking Apply Root motion solves the problem, but this does not work in my case.

avatar image vovo801 · Mar 18, 2015 at 02:16 PM 0
Share

I have also tried this: disable animator component, so that i can walk, move character on the platform, than in the middle of the game enable Animator. If I do so, the character teleports to the point where it was initially standing when I launched the game. The animation starts playing and showing properly if i press controls, but the player does not move.

1 Reply

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

Answer by vovo801 · Mar 18, 2015 at 08:09 PM

I have figured out the solution that worked for me.

First, I have created an empty game object and parented my game object to this newly created one.

Second, moved all the components from my first object to its parent, except for Animator component.

And it worked!!! Also had to rewrite my code a bit. When searching for Animator component had to change function GetComponent for GetComponentInChildren.

Hope this helps someone.

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

2 People are following this question.

avatar image avatar image

Related Questions

2D Animation does not start 1 Answer

Damn, HOW CAN I KNOW, IF MY 2d ANIMATION SPRITE IS FINISHED??!! 0 Answers

Best way to do animate soldier? 1 Answer

Animation transform lock 0 Answers

Not Run while Aiming; Slope Terrain Making Object Faster 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