I have a projecting raycast when i shoot, i want it so that if i shoot a collider with tag “head”, the raycast will hit that object and still go through and also hit whats behind it ( which could be another head, so double kill etc )
How can i achieve this? i have tried physics.raycastall but had no success.
var Hit : RaycastHit;
var DirectionRay = Bullet_Spawn.transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(Bullet_Spawn.transform.position , DirectionRay , Hit, Range)){
var hitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
if( Hit.collider){
Decals.transform.position = Hit.point;
var decalClone = Instantiate( Decals, Hit.point+(Hit.normal * DecalDis), hitRotation);
decalClone.transform.parent = Hit.transform;
Destroy(decalClone,8);
}
if( Hit.collider.CompareTag("Enemy")){
Hit.collider.SendMessageUpwards ("DoDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
if( Hit.collider.CompareTag("Head")){
Hit.collider.SendMessageUpwards ("DoDamageHead", Damage * 2, SendMessageOptions.DontRequireReceiver);
GetComponent(AudioSource).PlayOneShot(headShot);
}
if( Hit.rigidbody){
Hit.rigidbody.AddForceAtPosition( DirectionRay * Force, Hit.point);
}
}