kunal singh
kunal singh

Reputation: 33

Player is moving through the Wall in Unity 3D

I am making a simple game where the Player moves only Horizontally and the Enemies spawn from front. I created a Wall at the Left and Right side of the Player. But, Player keeps going through the Wall even when I have added Rigidbody component to Walls and Player. I used Cube gameobject to make a wall. Please help. Thank you!

Upvotes: 2

Views: 5358

Answers (3)

Mazhar Hussain Nomi
Mazhar Hussain Nomi

Reputation: 1

Add Box Collider to the object to make it collide with the walls.

Upvotes: 0

Lynxbird
Lynxbird

Reputation: 1

I have NavMesh agent on my player and what helped me:

  1. Mark walls (and other static objects) as static in inspector
  2. Go to Window->AI->Navigation and bake the scene

Upvotes: 0

Nikita Andrusov
Nikita Andrusov

Reputation: 41

  1. Do you have collider on walls and on player?
  2. If walls and player have colliders, check are theese colliders turned on and not triggers. (They should be turned on and checkbox "Is trigger" should be false)
  3. If previous steps completed and it still doesn't work, check Edit -> Project Settings -> Physics -> Layer collision matrix. And make sure that walls' layer collides with player's layer

Upvotes: 1

Related Questions