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 Siflou · Nov 20, 2013 at 10:53 AM · rigidbodyrigidbody2drigidbody.addforcerigidbody.velocity

Rigidbody2D adding force vs modifying velocity for character jump

Hey Guys,

I know that there is a lot of question of adding force versus velocity changes, but I'm using the Rigidbody2D from 4.3 version and I have a problem in my jump. For example, I give an initial force to my rigidbody, than if the player hold the button, I add like a small up force each 0.1 seconds. My problem is that The jump curve is not perfect because Each time that I add force, I can see that It makes a little peak in the curve. I was like, I could add less force each time, but if I dont add that much force, I don't see a difference. Then I began investigating modifying velocity directly. I'm still not sure of what is the difference between mRigidyBoddy.AddForce(Vector2.up * 10) and mRigidBody.velocity = mRigidBody.velocity + Vector2.up *10;. If some one could explain the difference clearly that would be great. Also, to fix my jump problem, I saw that in the normal rigidbody class, there was an AddRelativeForce, I don't know if it is the key to my problem. Does anybody has an idea ?

Thanks a lot for your time and have a good day :)

Claude

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 NicolasHognon · Apr 11, 2014 at 05:02 PM 0
Share

Hy Claude

did you find a solution to your problem because I have exactly the same I did find something satisfying. I am think about not using rigidbody2d.

avatar image Siflou · Apr 13, 2014 at 02:43 PM 0
Share

Hey there Nicolas,

I am resetting the y velocity and than adding a force after and it worked quite well for me.

Here's an example :

mRigidbody2D.velocity = new Vector2(mRigidbody2D.velocity.x,0); mRigidbody2D.AddForce(new Vector2(0,mJumpForce));

Hope it helps :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by smallbit · Nov 20, 2013 at 11:45 AM

Given that you have the framework to test, why you don't try yourself the difference between those two. From the physics point of view force and velocity are different magnitudes and in Unity behave way differently for instance when player is in the max height of jump (his velocity approaching to zero) add force will still make him jump (it will be added regardless his state position velocity) but velocity times 10 will not since his velocity is 0. etc...

If you continue moving player up and down in the gravity system you will always have peaks in the height, because player is actually facing opposite forces continuously(gravity vs your addforce) One thing I have in mind is to turn his rigidbody gravity field off (if it cannot be done just disable rigidbody on him) while you hold the button and after first iteration decrease the velocity or clamp it, well test it I cant say how it will work

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.

Follow this Question

Answers Answers and Comments

19 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

Related Questions

How can i initiate an object in parabolic motion without using gravity using Rigidbody2D? 0 Answers

Rigidbody.velocity seems to be breaking jumping physics 0 Answers

Any way to gracefully detach object with Unity physics? 2 Answers

Problems with Physics(Flipping strangely) 2 Answers

How can i initiate an object in parabolic motion without using gravity using Rigidbody2D? 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