• 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 hit 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. This has a few disadvantages, though, which make it an unattractive (albeit simple) solution.

That link has a raycast solution which should help. Beware spline ramps and stairs with this, 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 4
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. $$anonymous$$y 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
11

Answer by Max_power1965 · Dec 15, 2015 at 09:54 PM

There is new unity component called platform Effector 2D that will allow you to do that: more info here: http://docs.unity3d.com/Manual/class-PlatformEffector2D.html

Comment
Add comment · Show 3 · 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 taylorthurlow · Nov 14, 2016 at 01:49 AM 0
Share

This is great! For anyone looking to use this, just keep your existing 2D Collider and add a Platform Effector 2D. Check the "Used By Effector" box in your Collider.

avatar image bdilloughery_mvla · Dec 11, 2020 at 06:00 PM 0
Share

This was the solution (for 2D). It solves this problem without even changing any settings. Just add the "Platform Effector 2D" component, on your other collider check the "Used By Effector" checkbox to true ... then you are done. Though you probably want to uncheck the "One Way" setting in the Platform Effector 2D that is on by default depending on whether you want to use it. Solves the problem perfectly.

avatar image vraj95soni · Dec 22, 2020 at 02:42 PM 0
Share

This is not working for me. I have tried all methods mentioned in other comments also but still the player is getting stuck on wall

avatar image
6

Answer by GreenSignalGames · Apr 26, 2020 at 08:18 PM

For anyone else running into this issue, as I have a thousand times, I finally found a virtually perfect solution. On the character with the Rigidbody, you will also have a collider (usually a capsule collider). Copy that component, make the copy slightly wider, and slightly shorter, than the original. Match the height of the original, and then put the frictionless material on this collider. Now, the "feet" of your character will have the friction of the original capsule (you won't slide down slopes) but the "walls" of the new capsule will be what collides with other wall objects, and you will slide down them correctly. (image included for reference) alt text No need for any extra coding, raycasts, etc. Enjoy!


no-wall-stick.jpg (26.8 kB)
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 XyloBeta · Aug 04, 2020 at 07:05 PM 0
Share

Perfect for what I needed. It's similar to the process used in this GDC video: https://www.youtube.com/watch?v=LNids$$anonymous$$esxSE

avatar image
3

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

With this 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 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 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
1

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

How about attaching a trigger to the thing 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. $$anonymous$$y character can jump a bunch when next to a wall. Too bad there's no vertical istouchinglayer...

  • 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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

22 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

Related Questions

Raycast doesnt detect object in front of rigidbody (player is stuck on wall) 1 Answer

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

airplane collision detection problem 1 Answer

Detecting collisions with raycast or not? 1 Answer

Rigidbody stuck in colliders when moving and ricosheting. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges