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 arcantos9104 · Mar 26, 2014 at 01:58 AM · 2djumpaddforce

2d jumping, addForce hitting a max height despite force strength

So I have a pretty rudimentary physics-based jumping system, mainly I use rigidbody2d.AddForce to add a force to the up direction. When I use a small value, it does essentially nothing, as the value is just too small to do much of anything. However, after a certain level of force, the height of the jump maxes out and will not go any higher, even if I set the force to a ridiculous value. The mass of the rididbody2d is set to 1.

 //check for jumping
         if (inputY == 1 && grounded) {
             rigidbody2D.AddForce(Vector3.up * 1000000000000);
         }

that should be the only relevant code. The max point the gameobject reaches appears to be where his feet reach his head's initial position, and it happens instantly. Gravity does not reduce the object's velocity over any interval. Any thoughts/insights related to the subject are most welcome.

Comment
Add comment · Show 5
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 taylank · Mar 26, 2014 at 05:51 AM 0
Share

Are you setting the grounded boolean with another gameObject? Does that gameObject have a collider on it? Is that collider set to trigger? Could it be getting stuck with your ground object?

avatar image arcantos9104 · Mar 26, 2014 at 06:54 PM 0
Share

this is my code for setting the grounded boolean: grounded = Physics2D.Linecast (transform.position, GameObject.Find ("groundFinder").transform.position, 1 << Layer$$anonymous$$ask.NameToLayer ("ground"));

where "groundFinder" is a gameobject with only a transform component. It is located immediately below the character. I'm not sure what else could be relevant to the situation, I'm a little stuck at this point.

avatar image Leuthil · Mar 26, 2014 at 08:00 PM 0
Share

I don't think the grounded variable is the problem here. Without seeing your level it's hard to say. Could it be an invisible collider somewhere that is preventing it from continuing to jump? What kind of collider does the player have? Just a single capsule collider?

avatar image arcantos9104 · Mar 26, 2014 at 08:09 PM 0
Share

The player has a circle collider at his feet, and a box collider for his body. The character is not animated at this point. This happens no matter what position he jumps from. The character moves horizontally with AddForce in the right and left directions, and works just fine. It is a 2d sidescroller game. I don't know if a gameobject with multiple colliders can have those colliders somehow interfere with each other, I'm just taking shots in the dark.

avatar image Kiwasi · May 19, 2014 at 07:14 PM 0
Share

Do you have any rigid bodies that are children of other rigid bodies involved here?

This caused me some really weird physics behaviour.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TheFudster · May 19, 2014 at 08:09 AM

I'm seeing the same problem though I haven't solved it. There appears to be a cap on the amount of force that can be applied in one frame maybe? It's very strange. You can make it look good if you scale down your objects and use a smaller orthographic camera size. The demo uses Ortho size 11

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 Pyrian · May 19, 2014 at 12:15 PM

That grounded Linecast you're using looks like it's going to hit the Player's own collider and therefore always return true. Thus, you only get one frame of jumping regardless of how high you set the force.

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 TheFudster · May 19, 2014 at 02:28 PM 0
Share

Right but even if you only get ONE frame of AddForce shouldn't it still jump higher when you increase the force value? A larger force value should still accelerate the object to a higher velocity even if it is only one frame. However, we're not seeing that behavior. The acceleration in one single frame seems to be capped somehow.

avatar image Pyrian · May 19, 2014 at 06:49 PM 0
Share

I'm pretty sure that if you fix your single-frame problem, you're not going to be needing to worry about force/acceleration/velocity caps.

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

25 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

Related Questions

Accelerating speed 2 Answers

Character doesn't jump repeatedly 1 Answer

2d Beat Em Up Jump Functionality 0 Answers

Jumping from a floor to another floor (2D) 2 Answers

How do I add a jump function to my current script? 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