• 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
5
Question by drunkenoodle · Jun 07, 2012 at 01:54 PM · collisionrigidbodyraycaststuckwall

RigidBody stuck on wall when jumped against

Hello, I've recently been tinkering around with the Rigidbody component for a main character, although I seem to be running into a problem where should you jump against the wall, the object just kind of sticks there. Worse still, if you $$anonymous$$t jump at the same time, it shoots the Rigidbody into the air.

I found a couple of potential fixes using raycasts, although I wanted to make sure that there isn't just an simpler approach for detecting when you're colliding with a vertical surface as opposed to a horizontal one.

Many thanks!

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 zeal · Jun 07, 2012 at 10:26 PM 0
Share

I'd like to know the answer as well!

7 Replies

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

Answer by xandermacleod · Jul 16, 2012 at 01:12 PM

I had a similar problem. Here's what has been proposed:

http://forum.unity3d.com/threads/143698-Object-wont-fall-when-i-apply-horizontal-velocity-and-is-colliding-with-wall.

Your simple solution is to apply a new physics object to walls that has no friction. T$$anonymous$$s has a few disadvantages, though, w$$anonymous$$ch make it an unattractive (albeit simple) solution.

That link has a raycast solution w$$anonymous$$ch should help. Beware spline ramps and stairs with t$$anonymous$$s, though. :-)

Comment
Add comment · Show 5 · 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 Ellis · Nov 26, 2014 at 11:52 AM 0
Share

Thank you!

avatar image Jeepjump · Mar 29, 2016 at 01:06 AM 5
Share

This is a good solution. I think I can add to it. I had this same problem and I applied a physics material to the walls, which works like a charm. But then you run into the problem of having to apply physics materials to every obstacle in the game. Anyhow. My solution is to add an extra collider to the object and put the frictionless material on it like a belt.

![alt text][1] [1]: /storage/temp/66878-solution.png

Like that except transparent. This gives you the ability to move around freely but not get snagged on walls or messed up on hills. Plus you only use the physics material on one object.

It seems too easy to be true, but the thing works. I'm sure this will present some terrible unforeseen problem in the future, but for now it works.

solution.png (60.1 kB)
avatar image josephquested Jeepjump · Apr 24, 2016 at 03:23 AM 0
Share

I did almost exactly this. I'm using cubes so it is like a weird, invisible box my players live inside, but it worked great. It's a simple and effective way to apply different physics to floor/wall surfaces.

avatar image Afired Jeepjump · Jan 24, 2020 at 12:46 AM 0
Share

I know this is an old subject but for those who see this. You can change the default physic material in the project settings on the physics tab which can save you a lot of time. (main menu: Edit > Project Settings, then select the Physics category)

avatar image PointyPigheadGames · Nov 14, 2016 at 12:09 AM 0
Share

It worked for my platformer game!

avatar image
1

Answer by simonheartscake · Jun 07, 2012 at 11:23 PM

How about attac$$anonymous$$ng a trigger to the t$$anonymous$$ng you're jumping against and have a function that when inside that trigger makes your character unable to jump.

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 drunkenoodle · Jun 08, 2012 at 08:24 AM 0
Share

I'll have a play around with that idea, I think so long as the system knows that said surface is different to another, like you say, it should in theory stop the thing from going crazy.

Thank's for your help!

avatar image oliveTree3 · Nov 30, 2020 at 12:06 AM 0
Share

exactly what I was thinking. My character can jump a bunch when next to a wall. Too bad there's no vertical istouchinglayer...

avatar image
0

Answer by frankrs · Aug 15, 2014 at 07:56 PM

change your rigidbody2d components interpolate variable to exterpolate

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 CStunner · Jul 11, 2015 at 04:26 PM

i had t$$anonymous$$s issue once, i'm unable to exactly copy-past ecode, because it was a long time ago, maybe you too are writing your own character controller and also apply the gravity manually (yourself)?

if i remember correctly, my problem was that i kept my downward force code in the ELSE condition, i later removed it from Else and wrote it outside the IF ELSE condition w$$anonymous$$ch gathers the input and dpes the movement. t$$anonymous$$s meant that a constant force was applied regardless of what Input the game was getting. it was just a minor logical mistake really..

if you haven't already, you should raycast downwards and check if the Player is grounded or not also.

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
5

Answer by KINGSirDrMr · Nov 17, 2015 at 12:54 PM

With t$$anonymous$$s method, he still stuck to walls for me. I fixed it by changing the Friction & Bounce Combine settings from "Average" to "Multiply" with the Dynamic & Static Friction set to 0.

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 Siggytron · Feb 23, 2019 at 01:56 AM 1
Share

I did this on the object, and then on the walls I did this except that I set the Bounce for the walls to 0.1 so that they would repel my object slightly. That seemed to do the trick. Thanks for this solution.

avatar image awsapps · Mar 19, 2022 at 07:15 AM 0
Share

God bless you and all your family tree upwards and downwards until humanity extincs!

  • 1
  • 2
  • ›

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Why is CapsuleCast/Raycast performance effected by rigidbody? 1 Answer

airplane collision detection problem 1 Answer

Raycast doesn't register Rigidbody 1 Answer

Detecting collisions with raycast or not? 1 Answer

Bullet moves fast and makes a late collision.. 3 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