- Home /
Stop objects from going through each other with rigidbodies
okay, I'm trying to create a game where the player moves around using transform.translate. i put a rigidbody on him and all of his surrounding objects (walls in this case) to handle collisions
there's a problem. if the player runs into a wall he sort of moves into it, if you keep holding the foward button he pushes into it more so. It's gotten to the point that the character can push through to wall. overlapping the wall a bit is okay, but moving through it is something else entirely
If i push into a wall and stop going forward i get pushed away, but if not, again, i can move through walls
is there a way to make the rigidbody collisions stop you from moving entirely??? i have tried using rigidbody.addforce instead, but it still moves through the walls
i think i may need to use a character controller, but i don't know how to use them. i tried to learn a while back but it proved to be quite a hassle. is there anyway to do this with rigidbodies?
sorry this question is so vague, any and all help is greatly apprecieated
i forgot to note, all of the walls rigidbodies have all of their restraints checked and my object has all of it's rotation restraints checked
hope this helps
Go to:
Edit > Project Settings > Physics.
Reduce or set to 0 $$anonymous$$in Penalty for Penetration.
Go to:
Edit > Project Settings > Time
Reduce the value for 'Fixed Timestep'. I believe the default is 0.02. Try 0.01.
Neither of these are complete fixes, but often they can drastically reduce the problem. One issue is that if you moving through the transform, you are teleporting from one position to another. It can make collision detection fail.
thanks your code help the character a bit... but It still sort of presses into the wall which causes more problems then i cared to note before. so i am still stuck, thanks for the help though, it really does help, I just think that i am going to have to do this with a character controller
Answer by getyour411 · Apr 19, 2014 at 05:25 PM
The question you left a link to didn't help me at all. I don't understand why you put it as an answer.
The two solutions given to the persons problem were using velocity, which i said I tried addforce already (i tried velocity too but i thought saying that would be redundant) the other was to use a character controller, which i said i did not want to use
so are you telling me i need to learn to use a character controller? if not, please elaborate more than just posting a link to a question without explaining what i am supposed to understand from it.
Your answer
Follow this Question
Related Questions
Problem with CharacterController collision detection 1 Answer
Character not moving on slopes 1 Answer
How to handle movement in a multiplayer FPS? 0 Answers
character controller + physics 1 Answer