- Home /
RaycastHit on disabled CharacterController
Hi! I have a multiplayer game. There are two player instances. The one that you do NOT control, has it's CharacterController disabled. On my Character that HAS it's character controller enabled, I'm then initiated a RayCast. However, The RayCast is ignoring the CharacterController on the disabled player.. Could anyone help me out?
if(Physics.Raycast(shootAt, direction, out hit, Range)){
Debug.Log(hit.transform.name);
if (hit.collider.transform.tag != "characterPrefab" && hit.collider.transform.tag != "monsterCharacter")
{
var clone = Network.Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal), 99);
}
else if (hit.collider.transform.tag == "monsterCharacter")
{
Debug.Log("SPAWNING BLOOD");
Network.Instantiate(bloodSplat, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal), 199182);
}
}
Basically, The disabled character's tag is "monsterCharacter". However, according to my Debug.Log's, it is completely ignoring the character, and hitting behind it (i.e., terrain, trees, etc.)
I need to know how to make it hit the CharacterController, even if it's disabled (If that's even my problem :3)
I'm wanting a blood splat to be instantiated if it hits the "monsterCharacter", else a bullet hole..
Thanks in advance..
Answer by Seth-Bergman · Oct 08, 2013 at 08:13 PM
You can't hit a disabled component with a raycast, since it is disabled.. Instead, just add a collider to your monster, to give the ray something to hit..
Thanks! :) It was indeed due to the CharacterController being disabled. After closer exa$$anonymous$$ation, I came to the conclusion that I didn't need it disabled in the first place. So, I just re-enabled it and it works perfect now :) Thanks a ton!