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 bhavya_812 · Dec 04, 2013 at 02:12 PM · physicsunderstanding logic

JUMP LOGIC

I am trying to apply a JUMP effect on my game object. However I am doing this by applying force in y direction. However it is not giving an exact effect of jump as this force is not constant. How can I do this ?

Comment
Add comment · Show 1
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 Malfegor · Dec 04, 2013 at 03:16 PM 0
Share

What kind of movement logic are you using? Rigidbody, CharacterController or a Translate (or something else)?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by guitarxe · Dec 04, 2013 at 04:12 PM

If you want to use Unity's physics to accomplish this, then the logic is simple.

First you apply a large amount of force in the up direction, Vector3.up

 public int jumpForce;
 
 void FixedUpdate()
 {
   if(Input.GetKeyDown(KeyCode.Space)
   {
     gameObject.rigidbody.AddForce(Vector3.up * jumpForce);
   }
 }

  

Then, be sure your GameObject has a RigidBody component and it is using gravity. You can also check the physics settings of your project and modify the gravity settings, but by default these are set to real world -9.81 for the y axis.

This will first propel your GameObject up, and then unity will handle the gravity. If you do not see any movement when you apply the force, then you are not applying enough. Try higher values.

Alternatively, you can lower the mass of the object.

Of course, you'll need to write additional force to further the jumping logic, such as making sure the character cannot jump again while still in mid-air.

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

Answer by bhavya_812 · Dec 04, 2013 at 05:49 PM

However I have already tried this.. The force does not seem to stay constant

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 guitarxe · Dec 06, 2013 at 12:56 PM 0
Share

Of couse the object's velocity will not stay constant. There is gravity acting on it. What exactly do you want to accomplish, and what are you getting?

avatar image Malfegor · Dec 09, 2013 at 09:56 AM 0
Share

For a really basic movement script check the documentation of CharacterController.$$anonymous$$ove And just add a CharacterController to the GameObject you want to move.

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

18 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

Related Questions

2D 360 degress platformer example needed 0 Answers

physical force feedback 0 Answers

Strange Physics being applied to objects issue. 1 Answer

Rigidbody.MovePosition not really smooth 2 Answers

Rigidbody making object rotate despite locks 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