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 /
avatar image
0
Question by mjjja · Mar 15, 2018 at 01:06 AM · animation events

Changing only one axis(Transform.Position) in Animation Event

I'm first to unity engine and want to make a simple platformer game. Player's original X position is -6, and automatically moves forward changing position.x. I'd like to fix player's y position for between two keyframe when I play an animation, slowly increasing y position before first keyframe and decreasing to original y position after second keyframe. I tried this by adding four keyframes, setting first and last keyframes' position.y to original y value and second and third keyframes' position.y to increased y value. But when I only edit poision.y value, position.x value is automatically fixed to -6(original x value) and player does not move at all. Deleting all position.x keyframe value also yields same result, fixing player's x position. This problem occurs even when I don't play the animation, meaning player's position is fixed from the very beginning of the game. So here is the question : How can I edit only player's y value, not interfering x value?

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
1

Answer by Bunny83 · Mar 15, 2018 at 03:03 AM

You can't the localPosition is one property of type Vector3. Animation happens generally in local space. You generally want to avoid animating objects without a root object. You usually animate the child objects which allows you to place and rotate the parent as you like

Comment
Add comment · Show 2 · 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 mjjja · Mar 15, 2018 at 03:56 AM 0
Share

That means I can change localPosition if I put player object in a parent object? I tried to edit yPos in script but it moved awkwardly so I want to operate this in Animation Event. Can you guide me more?

avatar image Bunny83 mjjja · Mar 15, 2018 at 11:24 AM 0
Share

You don't just put the player object in a parent, but the parent object is your new player object. It's the one that should have the Animation or Animator component and all your player related scripts. Your animation would only animate the visual object which is a child of your actual parent object. Animations in generally animate a character or object in place.


I'm not sure what you mean by "Animation Event". An AnimationEvent is just a single point on the timeline of an animation that fires off an event (calls a method) once the animation passes this point. AnimationEvents have nothing to do with the actual animation (the movement / rotation of objects) but just give you an event at a certain time during the animation.


It's not really clear what this animation should represent or how your final movement should look like. If it should be something like a "jump" animation you usually don't "animate" it. A jump depends on the point where the player jumps off which isn't always the same height. Also a jump could be interrupted due to hitting an obstacle.

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

74 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 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

Can't make Spell structure and Animation with it 1 Answer

Set a Animation event state to a different gameobject state,Only let a certain animation event run when a certain GameObject is active 0 Answers

Animation event not firing when out of view 1 Answer

Animation event not always triggered 0 Answers

Mecanim animation layers and animation events 3 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