Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 13yearoldceo · Aug 17, 2015 at 10:45 PM · rigidbodyaddforcedamagexaxispushback

rigidbody2d.addforce for is not working for the x axis

i made it that when my character gets hurt or hit by an enemy it gets pushed by a pushback force caused by the damage by using addforce. The only problem is that the addforce only works for the y axis not the x even though its supposed to work for both, hears the code.

 if (pushback) { 
              GetComponent<Rigidbody2D>().AddForce( new Vector2(pushbackforcex,pushbackforcey),ForceMode2D.Impulse); 
              pushback = false;
          }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by plof27 · Jun 12, 2018 at 09:46 PM

I know I'm 3 years late on this, but I came across this post because I ran into the same problem. The solution for me was to uncheck Apply Root Motion on the objects Animator component. For some reason, this causes weird locking on some, but not all, axes even if there is no parent object int the hierarchy. Hopefully this helps any other lost souls who find themselves here years in the future.

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 Abercromby3 · Mar 14, 2020 at 11:17 PM 0
Share

2 years later: THAN$$anonymous$$ YOU

avatar image
2

Answer by Jackal14 · Jan 17, 2019 at 03:36 PM

I came across this error too and i think i found exactly, what the problem was, i'm not sure about disabling the animator because Apply Root Motion was already marked off in my project.

The exact reason for this problem is that your X axis component of RIgidbody is already being updated elsewhere at the same time when you are trying to create this KnockBack or Bounce. So check if there is any Conflict for X axis movement in the same script or if any other script is trying to access it. This Resolved it for me. Hope this helps!!

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 Seraian · Feb 22, 2021 at 09:57 PM 0
Share

This worked for me! My movement of my player was using the rigid-body.x axis as thus every update frame it kept altering it.

avatar image
0

Answer by kevinspawner · Aug 18, 2015 at 03:14 AM

From your one line code, I can only imagine swapping the pushbackforcex,pushbackforcey value to pushbackforcey,pushbackforcex. It would be easier to check the issue, if you can paste the full code.

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 13yearoldceo · Aug 22, 2015 at 12:14 AM 0
Share

don't worry i have solved it all i needed to do was add more force thank you

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

31 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

Related Questions

rigidbody2d.addforce for is not working for the x axis 0 Answers

Moving a ball through add force and rotate around 1 Answer

Rigidbody falling very slow 1 Answer

Grenade throw with indicator 0 Answers

Rigidbody movement conflict? 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