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 CharlesD · Aug 14, 2012 at 01:01 AM · rigidbodycolliderplayerjumping

Rigidbody Character Jumps Higher With At Least 2 Collisions

Hi, and thanks for taking the time to read my question. Lately I've been working on a rigid-body character controller for my next project, so far everything but the jumping is working correctly. If I just jump then it works fine... but if the player's rigid-body is colliding with any colliders then the player can jump just about twice as high (the more colliders, the higher the jump). The orientation of the colliders doesn't seem to matter just so long as they are touching the player in some way. This is the only code in the controller relating to jumping, and is very similar to that used in the rigid-body walker on the wiki (which also suffers the same problem). Ive tweaked the physics material of the player and walls and neither makes any difference in the behavior. Any insight at all would be greatly appreciated, thanks.

Edit: Almost forgot BodyController.cs is the full script i'm using. Edit Again: I just noticed that my jump height is in fact being altered when I collide with just one collider, but by very little, it seems that my height exponentially increases with the number of colliders.

private float CalculateJumpVerticalSpeed () { return Mathf.Sqrt(2 * JumpHeight * Gravity); } // Jump if (JumpKey && !CamController.isShaking && !CamController.Cinematic) { VelocityChange.y = CalculateJumpVerticalSpeed (); VelocityChange.y = (VelocityChange.y - Velocity.y); } rigidbody.AddForce (VelocityChange, ForceMode.VelocityChange); rigidbody.AddForce (new Vector3 (0, -Gravity * rigidbody.mass, 0));

[1]: /storage/temp/2761-testpackage.zip

bodycontroller_backup.txt (4.7 kB)
testpackage.zip (22.0 kB)
Comment
Add comment · Show 3
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 tobobox · Aug 14, 2012 at 02:42 AM 0
Share

I've had something similar happen. When my rigid body runs into another moving rigid body it jumps twice as high (without a jump call). This just randomly happens. I never figured out the solution.

avatar image Dakwamine · Aug 14, 2012 at 11:43 AM 0
Share

Please could you upload a $$anonymous$$imalistic unitypackage? I would like to debug in the same conditions as yours.

avatar image CharlesD · Aug 14, 2012 at 07:25 PM 0
Share

Of course, anything that helps. A package with everything you need (hopefully i didn't miss something, the code is a bit spread since i'm changing how i'm handling inputs) has been added as an attachment. Just place box-colliders with the "Walls" Physics material, a floor with no set physics material, and an instance of the Player prefab and you should be fine (you will have to set up the project input settings however). The problem is most noticeable when trying to jump in a corner formed by two walls.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by CharlesD · Aug 14, 2012 at 05:53 AM

Well, don't you just hate it when you ask a question only to have an epiphany hours later that solves it? I've been playing with the physics variables, changing the methods used for jumping, and running full line graphs on just about every variable I could find trying to understand whats wrong, and nothing has worked. As it turns out all I had to do was add a rigid-body component to all of the existing game-objects with colliders and set them to kinematic. Maybe there is something in the unity documentation that I missed, but I never knew that rigid-bodies wouldn't behave correctly if the objects they were colliding with didn't have rigid-bodies of their own. Hopefully this helps someone in the future.

Comment
Add comment · Show 4 · 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 hannesdvl · Mar 07, 2013 at 11:15 AM 0
Share

Really helpful solution to some strange Unity behavior. Helped a lot in maintaining a maximum jump height in a marble-like game. Thx!

avatar image CardTrick · Mar 28, 2014 at 02:26 AM 0
Share

This exact thing worked for me as well. I have no idea why this is the case though. Perhaps it's a bug.

avatar image Sinol · May 23, 2014 at 03:22 PM 0
Share

Thank you very much,CharlesD,your answer have solved my problem too! I have been confused with the similar problem for several days.$$anonymous$$y problem is that my ground is not just one object, it's a lot of blocks that combines it.If my player stand on the bound of the block or on two blocks the same time,my player will jump alomost twice higher than usual just like the above friend said.After I add rigidbody component to all my ground objects, it did solved the problem!!Thanks a lot, next time I will try character controller component ins$$anonymous$$d of the rigidbody.

avatar image sanjodev · Jul 29, 2014 at 05:38 PM 0
Share

Another victim of this issue. You try to be efficient by not using rigidbodys when you don't need it, and you get burned. This issue gave me a headache last night and put me to sleep. Great fix around what seems like a Unity bug.

avatar image
0

Answer by Tofa · Oct 31, 2014 at 11:28 AM

My answer to this is about 2 years too late :-), but may be useful for others who see this...

I propose that the issue here is the one I found here: http://answers.unity3d.com/questions/818801/why-are-rigidbody-interactions-only-consistent-whe.html

In short, if you are using Unity's gravity you may be experiencing this issue. If you use a custom gravity as described in the above link you can avoid having to set a whole bunch of objects to be rigidbodies.

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 Jakeaby · Aug 19, 2020 at 12:32 AM

Hello guys, I had this same issue but I was unable to fix it. I use unity 2019.3 and I fixed it by using rigidbody.velocity instead of the AddForce();.

Something like this: rigidbody.velocity = Vector2.up * jumpForce;

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

14 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

Related Questions

Detecting when Player stoped to push a rigidbody? 3 Answers

Make a collider NOT collide with CharacterController 1 Answer

Attach a Player to a moving GameObject 0 Answers

Raycast doesn't detect the ground when the player is on a ledge. 1 Answer

simple collision not working 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