• 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 lavendergoons · Nov 29, 2020 at 02:58 AM · gravityphysics2daddforceforcemode

Adding impulse force cancels out gravity force on collisions.

I trying to move my player using AddForce. I don't like the feel of using ForceMode2D.Force because it takes a while for the player to get up to speed and it seems to be constantly accelerating. I want to use ForceMode2D.Impulse because the movement is snappy and instant. However, when the player is falling or jumping and collides horizontally with a wall they don't fall but are stuck there against the wall (until I let off the inputs). If I use ForceMode2D.Force I don't have this issue the player hits the wall and will fall like expected.

I am applying gravity using AddForce as I want to be able to switch the direction of gravity.

Is there a way I can either:

1/ Make ForceMode2D.Force feel instant and snappy without constantly accelerating?

2/ Have ForceMode2D.Impulse not cancel out other AddForces?

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 sacredgeometry · Nov 29, 2020 at 04:13 AM 0
Share

If you attach a rocket to a person and then fire them against a wall would you expect them to fall?

The friction of the wall and body are the problem its otherwise behaving as expected. If you want it to slide down the wall reduce the friction and it will.

Otherwise you are basically saying "why don't my photos fall down when I nail them to a wall?"

avatar image sacredgeometry · Nov 29, 2020 at 04:15 AM 0
Share

How about instead of having the impulse happen whilst you are holding a button down you instead create a coroutine that triggers a single impulse or a short impulse over a period of time?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by julianbrezon · Nov 29, 2020 at 04:12 AM

If it only happens on collisions, try this:

  1. Create a new physics material in your project

  2. Set both frictions to 0

  3. Apply material to wall you're colliding with

  4. See if you still stick to it.

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 lavendergoons · Nov 29, 2020 at 04:22 AM 0
Share

That is one solution that is working for the walls but I have another scenario that it doesn't work for I forgot to mention. When I switch the gravity on the player and they are already falling, the Impulse force makes the gravity switch instant (like if i were to immediately change the velocity). If the player's gravity is the [0, -9.8] and I switch it to [9.8, 0] then the Impulse force will stop any movement on the Y axis and immediately transition gravity the the X axis. With the Force$$anonymous$$ode2D.Force, the player will keep their Y velocity from the old gravity as well as take on velocity from the new gravity causing them to fall in a parabola motion. I was hoping to keep that because it feels more realistic.

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

152 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 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 avatar image avatar image avatar image avatar image

Related Questions

How do i make the Impulse i give to my Player not be lowered by acceleration of gravity? 1 Answer

Simple question about unity 5 rigidbody/gravity 1 Answer

Need help on my script to calculate gravity for a mass 1 Answer

physics based path system? 1 Answer

Foces only change during collision 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