Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Basic/2DSpaceShooter/Assets/Scripts/ShipControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directive can be removed!

using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
Expand Down Expand Up @@ -194,7 +195,7 @@ public void TakeDamage(int amount)

void Fire(Vector3 direction)
{
fireSound.Play();
PlayFireSoundClientRpc();

var damage = 5;
if (QuadDamageTimer.Value > NetworkManager.ServerTime.TimeAsFloat)
Expand All @@ -215,6 +216,7 @@ void Fire(Vector3 direction)
bullet.SetVelocity(velocity);

}


void Update()
{
Expand Down Expand Up @@ -498,6 +500,12 @@ void OnCollisionEnter2D(Collision2D other)
TakeDamage(5);
}
}
// --- ClientRPCs ---
[ClientRpc]
void PlayFireSoundClientRpc()
{
fireSound.Play();
}

// --- ServerRPCs ---

Expand Down Expand Up @@ -537,7 +545,7 @@ public void FireServerRpc()
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extra space should be removed!

[ServerRpc]
public void SetNameServerRpc(string name)
{
Expand Down