- Home /
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!
Answer by xandermacleod · Jul 16, 2012 at 01:12 PM
I had a similar problem. Here's what has been proposed:
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. :-)
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.
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.
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)
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
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.
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.
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
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) No need for any extra coding, raycasts, etc. Enjoy!
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
oh my god. so simple, why didnt i think of this sooner?? thanks!
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.
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.
God bless you and all your family tree upwards and downwards until humanity extincs!
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.
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!
exactly what I was thinking. $$anonymous$$y character can jump a bunch when next to a wall. Too bad there's no vertical istouchinglayer...
Your answer
Follow this Question
Related Questions
Rigidbody stuck in colliders when moving and ricosheting. 0 Answers
Detecting collision on start in my building system 0 Answers
How do I change Raycast's direction based on movement input? 1 Answer
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