Object goes through wall (both have RigidBody and Collider attached)
Player can easily go through walls, while player and the wall have RigidBodys and Colliders attached. Please help!
Player settings:
Wall settings:
Answer by DawdleDev · May 01, 2018 at 04:00 PM
There are a lot of possible reasons for this. First, are you using transform.Translate, rigidbody.velocity, or rigidbody.addforce? The last two are the only ones that prevent you from walking through anything. I see that your player's rigidbody is kinematic. Try setting it to dynamic and use rigidbody.velocity. That's the most likely reason here. Second, what layer is everything on? Try setting all of the objects that you want to collide with each other to the default layer. It might be that you set them on layers that don't collide with each other.
Hope this helps!
Thanks for your help, but honestly, I tried everything.
As I figured out, it doesn't even collide with the walls... That's the code for Player: void OnCollisionEnter(Collision collidedObject) { if (collidedObject.transform.tag == "Walls") { Debug.Log("I collided with the wall!"); speed = 0f; } }
And it doesn't say that message when actually going through the wall :(
$$anonymous$$aybe I'm too wrong.
I wrote a big and detailed answer to say thank you and that it worked... But then my laptop started lagging and the answer dissapered. so.... Thanks!
Answer by cyberIndia · Sep 15, 2020 at 11:42 AM
thanks.. replacing transform manipulation by rigidbody did the trick... thanks a lot..
Your answer
![](https://koobas.hobune.stream/wayback/20220612161833im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Detecting collisions on an invisible grid 0 Answers
Unity 5: AddForce Increases power when already being pushed towards a collider. How to make stop? 1 Answer
Moving a cube with RigidBody. MovePostition, it randomly stops moving 0 Answers
Ball passes through the floor on movement 1 Answer
Collision/UI/Rigidbody? 0 Answers