Why the object can go through doors and walls even if i add to it a collider ?

I tried to add to it a Rigidbody and played with the Use Gravity and Is Kinematic checked them both unchecked nothing helped.
Then i added box collider played with the Is Trigger on/off i changed the box collider size to be a bit bigger then the object but it didn’t change anything. Then i tried capsule collider and mesh collider.

Tried all this components to attach to the NANI and then to the Droid_Player but nothing changed.

In the Hierarchy the NAVI have childs some of them for example all the polySurface have mesh collider component attached already. I tried to play with this colliders too. But so far nothing helped.

The NAVI (Droid) can move through doors and walls and the ceiling the floor anything.
And i want it to act like the FPSController > FirstPersonCharacter that he can’t move through walls doors and other objects. I want to make the Droid(NAVI) like part of the FPSController > FirstPersonCharacter.

I tried before to make the NAVI child of the FirstPersonController but same problem the NAVI is moving through walls doors anything.

Not necessarily enough information here. To interact with physics for an object like, I would say that the simplest approach would be:

  1. choose the primitive collider that best matches the shape. (or use more than 1 if you really have to, to build the shape*) – Not set as a trigger.
  2. add a rigidbody, non-kinematic
  3. move the game object with physics (add force / velocity).
  4. of course, there must be colliders on doors/walls, too.

May not be the only way, but that should prevent going through walls.

1 Like

UPDATE to what i tried and did so far:

From the NAVI (Droid) i removed the box collider component and added two things:

  • Character Controller component

  • Control script (This script is coming with the NAVI(Droid))

This is the Control script:

using UnityEngine;
using System.Collections;

public class Control : MonoBehaviour
{
   public float rotationDamping = 20f;
   public float speed = 10f;
   public int gravity = 0;
   public Animator animator;

   float verticalVel;  // Used for continuing momentum while in air   
   CharacterController controller;

   void Start()
   {
       controller = (CharacterController)GetComponent(typeof(CharacterController));
   }

   float UpdateMovement()
   {
       // Movement
       float x = Input.GetAxis("Horizontal");
       float z = Input.GetAxis("Vertical");

       Vector3 inputVec = new Vector3(x, 0, z);
       inputVec *= speed;

       controller.Move((inputVec + Vector3.up * -gravity + new Vector3(0, verticalVel, 0)) * Time.deltaTime);

       // Rotation
       if (inputVec != Vector3.zero)
           transform.rotation = Quaternion.Slerp(transform.rotation,
                                                 Quaternion.LookRotation(inputVec),
                                                 Time.deltaTime * rotationDamping);

       return inputVec.magnitude;
   }

   void AnimationControl ()
   {
       if(Input.GetKey("a") || Input.GetKey("s") || Input.GetKey("d") || Input.GetKey("w"))
       {
           animator.SetBool ("Moving" , true);
       }
       else
       {
           animator.SetBool ("Moving" , false);
       }

       if(Input.GetKey("space"))
       {
           animator.SetBool ("Angry" , true);
       }
       else
       {
           animator.SetBool ("Angry" , false);
       }

       if(Input.GetKey("mouse 0"))
       {
           animator.SetBool ("Scared" , true);
       }
       else
       {
           animator.SetBool ("Scared" , false);
       }

   }

   void Update()
   {   
       UpdateMovement();
       AnimationControl();


       if ( controller.isGrounded )
           verticalVel = 0f;// Remove any persistent velocity after landing
   }
}

Now when i move the character close to a door or wall also the NAVI(Droid) stop and is not moving through the door or wall and this is fine. But now i have another problem. If i will keep moving to the door or wall it looks like the character is moving over/on the NAVI Droid.

The Navi droid is not changing position.

In this screenshot is how it looks like when i moved close to the door the collider on the door and the NAVI Droid are working and the navi droid can’t move through the door:

In this screenshot you can see what is happened when i kept moving the character to the door. On the top screen view the NAVI droid is in the same position but on the Game View on the bottom it seems like the character is moving over/on the NAVI droid.

And if i will keep moving to the door the character will not move but the droid looks like pushed back or the character will keep moving over the droid.

I tried to add also Rigidbody to the NAVI Droid but it didn’t change much and if i don’t set the Is Kinematic to true i will get error: Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5.

But anyway the Rigidbody didn’t help much.

And this is a small shot video clip i recorded showing the problem.
You can see the problem in the bottom game view window on the left:

The problem start from second 20: