# Why when adding a box collider to character i can still walk through the character?

Like the box collider is not active or exist. I added a box collider on the left soldier.

I'm using firstpersoncontroller and firstpersoncharacter as player but i can move through the soldier and when the mouse cursor is over the soldier it's not detecting it as "Interactable" object.

The only object that is detecting is the door behind the soldiers. Any other objects are not detecting using the ray cast. So i added a box collider to the soldier for testing but it's not working.

Can't figure out why only the door is detecting.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraRaycast : MonoBehaviour
{
Ray ray;
RaycastHit hit;

void Update()
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 1000))
{
if (hit.transform.tag == "Interactable")
{
print("Hitted on: " + hit.transform.name);
}
}
}
}

• Try setting "isTrigger" to false – Bálint Nov 9 '17 at 23:25
• @Bálint setting it off make it work but why when running the game it's not detecting the soldier only if i move close enough to it ? And then if i will go far from it will keep detect the soldier but first time running the game it's not detecting it when the mouse is over the soldier. But if it's the door it will detect the door. Strange. – Daniel Lip Nov 9 '17 at 23:50
• Do you happen to start very close to this soldier, where the ray might have its origin inside the collider, rather than outside? Rays only detect intersections on the way in, not on the way out. ;) – DMGregory Nov 9 '17 at 23:55
• @DMGregory Might be too close since the game start in a room. Maybe i should find another way to interact with objects/NPC's. What other ways there are ? – Daniel Lip Nov 10 '17 at 0:10
• Can we also see the door (scripts on it etc.) that is being detected? There may be more variables present (like layers or tags etc.). – John Hamilton Nov 10 '17 at 8:00