Added PlayerMovement and other
This commit is contained in:
@@ -11,22 +11,32 @@ public class PlayerShoot : NetworkBehaviour
|
||||
|
||||
private PlayerHealth playerHealth;
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
private bool isActive = false;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (IsOwner)
|
||||
{
|
||||
playerHealth = GetComponent<PlayerHealth>();
|
||||
if (playerHealth == null)
|
||||
{
|
||||
Debug.LogError("PlayerHealth component not found on player");
|
||||
}
|
||||
}
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
|
||||
// public override void OnNetworkSpawn()
|
||||
// {
|
||||
// if (IsOwner)
|
||||
// {
|
||||
// playerHealth = GetComponent<PlayerHealth>();
|
||||
// if (playerHealth == null)
|
||||
// {
|
||||
// Debug.LogError("PlayerHealth component not found on player");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!IsOwner) return;
|
||||
|
||||
if(!isActive) return;
|
||||
|
||||
playerHealth = GetComponent<PlayerHealth>();
|
||||
|
||||
if(playerHealth == null || playerHealth.isDead.Value) return;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
@@ -59,7 +69,7 @@ public class PlayerShoot : NetworkBehaviour
|
||||
[ClientRpc]
|
||||
private void SpawnHitEffectClientRpc(Vector3 _hitPosition)
|
||||
{
|
||||
Debug.Log($"Spawning hit effect at {_hitPosition}");
|
||||
// Debug.Log($"Spawning hit effect at {_hitPosition}");
|
||||
Instantiate(hitEffectPrefab, _hitPosition, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user