• 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 DubSket · May 31, 2014 at 06:00 PM · c#animationlocalposition

Object's local position not being changed properly

I'm having a problem where I'm adding a recoil effect to a gun's local position through code every time Fire1 is hit, but the position doesn't seem to be effected.

I currently have an animation created in the Unity animator for when the gun isn't shooting, an Idle effect, which is being used instead of the recoil. I've done some basic debugging and found that the Vectors being produced and fed to the model aren't the issue, so I'm not really sure what it could be.

Any help would be really appreciated,

Thanks.

Comment
Add comment · Show 7
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 meat5000 ♦ · May 31, 2014 at 06:14 PM 0
Share

You are doing this in $$anonymous$$ecanim - Animator?

avatar image DubSket · May 31, 2014 at 06:24 PM 0
Share

No, I'm using the Animation Window (Ctrl+6 on Windows), just for the idle, though. The Recoil is coded.

avatar image meat5000 ♦ · May 31, 2014 at 06:28 PM 0
Share

And the curves appear correctly in the window? Have you tried adjusting something else like scale to see if it works?

avatar image Jeff-Kesselman · May 31, 2014 at 06:31 PM 0
Share

Are you running an animation during the recoil period? That could be overriding your recoil settings.

avatar image DubSket · May 31, 2014 at 06:35 PM 0
Share

@$$anonymous$$eat5000: The curves are appearing fine, and the idle animation is fine. It just seems to be playing when I don't want it to.

@Jeff: I was starting to think something like this might be the issue. Unfortunately, I don't really know how to check to see if that's the case. I haven't really set up animations before.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jeff-Kesselman · May 31, 2014 at 06:45 PM

Well, you can stop all animations while you do the recoil using Animation.Stop()

But be aware that as soon as you restart animations its going to return to the first position in the animation being played.

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 DubSket · May 31, 2014 at 06:51 PM 0
Share

@Jeff $$anonymous$$esselman

Thanks this solved the problem!

avatar image meat5000 ♦ · May 31, 2014 at 07:05 PM 0
Share

Accept the answer, converted from comment

avatar image
0

Answer by tanuj0092 · May 31, 2014 at 06:59 PM

After looking at your question, following are the cases : 1. Is your animation event animation.play is constantly fired in update or whatever function, This can block your recoil effect as the idle gun animation is position based as legacy animations are dependent upon positions. If this is the case then you should stop the animation before firing recoil event and resume it afterwards. 2. Please check whether the position of the whole object is being changed or not. If so then try using transform.localposition.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

AI Animation problems 1 Answer

Smooth transition from Camera1 to Camera2? 1 Answer

Mouse move to control the animation 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