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 Karmak · Jan 20, 2014 at 02:40 AM · animationgameobjectposition

Changing position of GameObject with Animation

Hello,

I am having problem with dynamic change of GameObject position (e.g. transform.position,...) which has attached animation(s) to it. It doesn´t do anything.

It seems like the existing animation(s) override my commands for position change, even if these animations are not being played.

Once I delete all existing animations of the GameObject, I can change its position again as expected.

Is this behaviour to be expected? How do I get around it?

Thank you all for your thoughts!

George

Comment
Add comment · Show 5
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 Grieve_physics · Jan 20, 2014 at 04:23 AM 0
Share

Any chance to share your code to see how the transform.position is called and animations.

Also are you using mecanim, or the legacy animation system?

avatar image Karmak · Jan 20, 2014 at 12:46 PM 0
Share

The code is: myGameObject.transform.position = Vector3(0,1,2);

This doesn´t work as long as animations are attached to it through Animator - I guess that´s mecanim?

avatar image Grieve_physics · Jan 20, 2014 at 01:22 PM 0
Share

As a guess, it seems you may be using $$anonymous$$ecanim. WIth the GameObject selected, In the inspector Window, Under the Animator Component. Try disabling "Apply Root $$anonymous$$otion" and see how that goes. $$anonymous$$eep me posted.

avatar image Karmak · Jan 20, 2014 at 02:42 PM 0
Share

Disabling "Apply Root $$anonymous$$otion" didn´t work. As you can see in the answer below from ibzy, this problem is actually limitation of Unity. You can very easily mimic the situation. Before I succumb to the untidy way of parenting the GameObject, I´d like to know how others solve this issue. Literally every developer got to stumble upon this, yet I don´t see anybody solving this.

avatar image Grieve_physics · Jan 21, 2014 at 01:52 AM 0
Share

Ah, $$anonymous$$isunderstood the question. Cheers

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Ibzy · Jan 20, 2014 at 02:34 PM

Hi George,

I had a similar problem myself, so to get around it I had an empty GameObject as a mounting point, and the animated object as a child set to 0,0,0. When moving the object with transform.position, I would use myGameObject.transform.parent.transform.position - this would move the mounting point while leaving the child at 0,0,0.

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 Karmak · Jan 20, 2014 at 03:02 PM 0
Share

Hey Ibzi, thanks for sharing your solution. $$anonymous$$y personal hack is to dynamically create copy of the sprite, and hide the original, so my hierarchy is not messed up. But I will surely keep this in my arsenal of solutions.

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

20 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

Related Questions

Object's sprite and collider are not at same position as transform 1 Answer

Update character's position after animation 1 Answer

Animation position change 0 Answers

How to tell if 2 blocks are next to each other in a 2d game? 1 Answer

Position and rotation of a game object acting wired 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