protected virtual void Fire(Transform origin) { GameObject prefab = projectilePrefab; var projectile = prefab.GetComponent <Projectile>(); int faceIndex = -1; string playerID = ""; if (delivery == ProjectileDeliveryMethod.Rigidbody) { var projectileInstance = projectile.isPooled ? NetworkObjectPool.Instance.GetInstance(prefab) : Instantiate(prefab); projectileInstance.transform.position = origin.position; projectileInstance.transform.rotation = origin.rotation; if (!projectile.isPooled) { projectileInstance.gameObject.SetActive(true); NetworkServer.Spawn(projectileInstance); } if (OnProjectileSpawned != null) { OnProjectileSpawned.Invoke(projectileInstance); } RpcFire(projectileInstance); } else if (delivery == ProjectileDeliveryMethod.Raycast) { var hit = new RaycastHit(); if (Physics.Raycast(origin.position, origin.forward, out hit, 100.0f, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Ignore)) { Debug.DrawRay(origin.position, origin.forward, Color.green); var damageable = hit.transform.GetComponentInParent <Damageable>(); if (damageable && projectile) { damageable.RaycastHit(projectile.profile.damage, prefab, hit, m_Owner); if (!damageable.Alive) { //damageable.Hit(projectile.profile.damage, projectile.gameObject, null, false, hit.point.x, hit.point.y, hit.point.z); DestructableObject dest = hit.transform.GetComponent <DestructableObject>(); if (dest != null) { Vector3 vel = origin.forward * projectile.profile.speed; float mass = projectile.GetComponent <Rigidbody>().mass; dest.RaycastDestruct(mass, vel); dest.RpcRaycastDestruct(mass, vel); } } } // Face damage BulletTriggerForFace btff = (BulletTriggerForFace)hit.transform.GetComponent(typeof(BulletTriggerForFace)); if (btff != null) { faceIndex = btff.FindHitIndex(hit.point); playerID = btff.playerRef.sPlrData.playerID; } } OnProjectileRaycast.Invoke(projectile, hit); RpcRaycast(origin.position, origin.forward, faceIndex, playerID); } }