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 /
This question was closed Mar 28, 2014 at 11:18 AM by 2d4Games for the following reason:

Workaround-ed

avatar image
0
Question by 2d4Games · Mar 24, 2014 at 03:23 PM · rigidbodyaddforcemesh colliderboundary

Rigidbody addForce when colliding with 2 mesh colliders

I have a character with a rigidbody and a box collider, and I am using mesh colliders along different chunks of ground to walk on. The character jumps with rigidbody.AddForce(Vector3.up * jumpForce). This works fine when the character is on a single chunk (middle or corner), but if he stands at a point where two sections meet (where he collides with both), his jump height gets cut down (about 1/4 or less what it should be). Does anyone know what might be causing this issue?

Comment
Add comment · Show 10
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 highpockets · Mar 24, 2014 at 04:20 PM 0
Share

This will be a tough one to solve without your code

avatar image benni05 · Mar 24, 2014 at 04:23 PM 0
Share

Without a more detailed description/visualization of where your colliders are in relation to the character this is very hard to say. It sounds to me that the character is not affected by anything when jumping and would just land again on the ground where he took off (the mesh colliders). If this is so then even friction (which is the first thought I had) would not come into effect. But if for example he moves sideways while/before jumping maybe friction comes into play here... please post more detail.

avatar image Amitabha · Mar 24, 2014 at 04:27 PM 0
Share

What is the type of character (Cube,Sphere etc) ?

avatar image 2d4Games · Mar 24, 2014 at 05:18 PM 0
Share

Thanks for the initial replies, I'll try to give a better picture of what is going on.

There are 3 objects: Character: with a rigidbody and a box collider Ground 1: with a mesh collider Ground 2: with a mesh collider

 Ground 1 & 2 are below Character (with respect to y), and Character is being held to them by gravity.

The relevant code (JS) is: var jumpForce : float = 4000; rigidbody.AddForce(Vector3.up * jumpForce);

If Character is standing anywhere on Ground 1, and not touching Ground 2, the jump works as expected. The same if he is on Ground 2, not touching Ground 1

If Character is touching Ground 1 and Ground 2, and jumps, the jump height is cut down significantly. This occurs regardless of x movement (the game is 2D, so z movement is not involved).

I see this issue whether or not Ground 1 & 2 are touching each other.

As mentioned, the game is 2D. I am using 2D Toolkit for sprites, and all colliders are their normal 3D versions, since development began before the introduction of 2D colliders.

avatar image benni05 · Mar 26, 2014 at 02:16 PM 1
Share

Ok, got it. Preferably you call all Physics related methods in FixedUpdate, yes. Please read the manual regarding this. It really is only required if you want to apply a force over several frames. The Input.GetButtonDown should be called in Update though - as you did. This becomes relevant if the game frame rate is higher than the Physics engine frame rate. You want to receive the GetButtonDown event and this can only be assured in Update. You would then for example set a state which is then queried in FixedUpdate and triggers the jump. But you can leave it as it is for now. Have you looked into the friction settings? Are any Physics $$anonymous$$aterials involved?

Show more comments

1 Reply

  • Sort: 
avatar image
0

Answer by 2d4Games · Mar 28, 2014 at 11:16 AM

This isn't really a solution, more of a work-around.

I was able to rework the script to set the velocity directly, rather than add a force to the rigidbody. This new method does not have the issue.

Thanks everyone for the help in debugging this problem.

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 Leuthil · Mar 28, 2014 at 05:21 PM 0
Share

Interesting. It may be worth noting that I think the proper way to do a jump by using AddForce is to pass in the optional second parameter in the AddForce function to Force$$anonymous$$ode.Impulse. I'm not sure if that would also fix your issue then, considering setting the velocity directly did.

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

Trouble in freezing movement in z axis 1 Answer

AddForce to opposite direction 2 Answers

Addforce to ball in camera position 0 Answers

Add Force when level loads 2 Answers

AddForce wont apply force to gameobject...help please 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