- Home /
Player passes through walls
Player game object passes through walls.
Rigidbodies are not registering collision.
How can I fix it?
Answer by rob5300 · Jan 14, 2016 at 11:12 AM
Check how you are moving the player. There are a few reasons for why this could be happening:
If you are moving the player via physics, this should not happen. It then could be causes by various things such as the max penetration value in the Physics settings.
Remember of course all objects need colliders on them. Something you may not know is that two mesh colliders will not collider unless one is ether a Static object, or one is marked as Convex. This is built into Unity to prevent physics issues. If this is the case, try replacing the colliders with primitives such as Box colliders and test.
EDIT: Seems now in unity 5 its slightly different, here is what the doc says:
There are some limitations when using the Mesh Collider. Non-convex Mesh Colliders are only supported on GameObjects without a rigidbody. If you want to use a Mesh Collider on a rigidbody, it needs to be marked as Convex.
If you are moving the player via its transform.position, then you are going to encounter these issues, as there is no reasonable way for the engine to check if the player will collide until the next physics update.
Can you give us the code you are using to move the player? Preferably the whole script.
Thanks. Your answer helped in my case as well. Especially, the part,
It then could be caused by various things sub as the max penetration value in the Physics settings.
In my case, two game objects with collider penetrated or went through each other only when speed is higher than some extent, and I needed to configure the penetration in Physics configuration.
However, it took time to get to where I can configure the penetration. After all, I found that it seems to be called Contact Offset at the moment of version 2017.3.0f3. It is available at Physics $$anonymous$$anager that can be opened from Edit - Project Settings - Physics, but keep it in $$anonymous$$d that it is a default value. When it comes to individual, it seems not to be available on Inspector, although it is configurable in scripting, which is something looks like GetComponent<BoxCollider>().contactOffset = 5f
Hello rob. I have problems with player passes through walls. I'm using transform.position. What can i do?
CODE:
joystick giriliVAl;
Rigidbody2D mybody;
public float speed;
void Start()
{
giriliVAl = GameObject.FindGameObjectWithTag("Joystick").GetComponent<joystick>();
}
void Update()
{
transform.position += giriliVAl.giriliV * Time.deltaTime * speed;
}
}
Answer by seedoubleyou · Nov 15, 2011 at 05:49 AM
Do all your objects have Colliders on them? Are the Collider's "Is Triggers" box clicked on? (That's what used to get me in trouble)
all what you mention to do are done ,but still it pass the wall !!
I also have this problem, but I don't now what i can to do... I searching on internet but there haven't fix....
Answer by Rocketman123 · Sep 28, 2016 at 08:43 PM
even though i am a total noob (so don't take my word for it) the answer is to make the wall & floor (instead of a plane) into a cube that is thick. this partily solved my problems at least.
Answer by akale · Jan 15, 2016 at 05:43 PM
It is not Rigidbodies that register walls, its box colliders(or box colliders 2d). Try adding some colliders
Answer by SterlingSoftworks · Jan 15, 2016 at 06:31 PM
If you have a Rigidbody and all the proper Colliders and you're not ignoring the collisions via code or anything like that.. Try setting your Rigidbody's Collision Detection to "Continuous".
Discrete Detection: Checks the next frame "Is the collider touching another collider in this frame? If not, move there, if so, we collided"
Continuous Detection: Fires a Raycast in the direction of movement to check the collision before they happen.
Your answer
![](https://koobas.hobune.stream/wayback/20220613043216im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to check direction of wall on character controller hit? 2 Answers
Problem with health and level reload system 2 Answers
Player is moving through walls when force is added from a knockback script? *UNANSWERED* 3 Answers
Gun goes through walls (FPS) 1 Answer
I have a problem with implementing a health and death system, help? 1 Answer