I’m building a horror game . In that game I use a gun . When I shoot a shot of gun it’s didn’t collide with player. it’s collide with other objects which is behind it ( by the way my characters collider is isTrigger , true). this is my code "
type or paste code here`
public void Shoot()
{
gunShotAni.Play("Gun Shot");
RaycastHit shootHit;
if (Physics.Raycast(fpsController.transform.position, fpsController.transform.forward, out shootHit, 50f))
{
Debug.Log("RayCast hit with " + shootHit.collider.name);
if (shootHit.collider.isTrigger)
{
Rigidbody rb = shootHit.collider.GetComponent<Rigidbody>();
rb.AddForce(Vector3.back * 10, ForceMode.Impulse);
Animator animator = shootHit.collider.GetComponent<Animator>();
animator.Play(zombieHitReaction);
EnemyMove enemy = shootHit.collider.GetComponent<EnemyMove>();
enemy.TakeDamage();
}
else if (shootHit.collider.CompareTag("Finish"))
{
Rigidbody rb = shootHit.collider.GetComponent<Rigidbody>();
rb.AddForce(Vector3.back * 10, ForceMode.Impulse);
}
}
} "`