Added UI and more
This commit is contained in:
@@ -10,37 +10,27 @@ public class PlayerShoot : NetworkBehaviour
|
||||
[SerializeField] GameObject hitEffectPrefab;
|
||||
|
||||
private PlayerHealth playerHealth;
|
||||
private WeaponView weaponView;
|
||||
|
||||
private bool isActive = false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
isActive = true;
|
||||
|
||||
playerHealth = GetComponent<PlayerHealth>();
|
||||
weaponView = GetComponentInChildren<WeaponView>(true);
|
||||
}
|
||||
|
||||
|
||||
// public override void OnNetworkSpawn()
|
||||
// {
|
||||
// if (IsOwner)
|
||||
// {
|
||||
// playerHealth = GetComponent<PlayerHealth>();
|
||||
// if (playerHealth == null)
|
||||
// {
|
||||
// Debug.LogError("PlayerHealth component not found on player");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(!isActive) return;
|
||||
if (!isActive) return;
|
||||
|
||||
playerHealth = GetComponent<PlayerHealth>();
|
||||
|
||||
if(playerHealth == null || playerHealth.isDead.Value) return;
|
||||
if (playerHealth == null || playerHealth.isDead.Value) return;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
weaponView?.PlayShoot();
|
||||
ShootServerRpc(cameraRoot.position, cameraRoot.forward);
|
||||
}
|
||||
}
|
||||
@@ -48,6 +38,9 @@ public class PlayerShoot : NetworkBehaviour
|
||||
[ServerRpc]
|
||||
private void ShootServerRpc(Vector3 _origin, Vector3 _direction)
|
||||
{
|
||||
// Записываем выстрел для клона — ровно то, что пришло в RPC
|
||||
GetComponent<GhostRecorder>()?.RecordShot(_origin, _direction);
|
||||
|
||||
Collider[] ownerColliders = GetComponentsInChildren<Collider>();
|
||||
|
||||
if (Physics.Raycast(_origin, _direction, out RaycastHit _hit, range))
|
||||
@@ -72,4 +65,4 @@ public class PlayerShoot : NetworkBehaviour
|
||||
// Debug.Log($"Spawning hit effect at {_hitPosition}");
|
||||
Instantiate(hitEffectPrefab, _hitPosition, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user