File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Basic/Invaders/Assets/Scripts Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ private void OnTriggerEnter2D(Collider2D collider)
36
36
{
37
37
owner . IncreasePlayerScore ( hitEnemy . score ) ;
38
38
39
- Destroy ( hitEnemy . gameObject ) ;
39
+ if ( NetworkManager . Singleton . IsServer )
40
+ {
41
+ // Only the server can despawn a NetworkObject
42
+ hitEnemy . NetworkObject . Despawn ( ) ;
43
+ }
44
+
40
45
Destroy ( gameObject ) ;
41
46
42
47
// this instantiates at the position of the bullet, there is an offset in the Y axis on the
Original file line number Diff line number Diff line change 1
1
using Unity . Netcode ;
2
2
using UnityEngine ;
3
3
4
- public class SuperEnemyMovement : MonoBehaviour
4
+ public class SuperEnemyMovement : NetworkBehaviour
5
5
{
6
6
private const float k_YBoundary = 14.0f ;
7
7
8
8
// The constant speed at which the Bullet travels
9
9
[ Header ( "Movement Settings" ) ]
10
10
[ SerializeField ]
11
- [ Tooltip ( "The constant speed at which the Sauce moves" ) ]
11
+ [ Tooltip ( "The constant speed at which the Saucer moves" ) ]
12
12
private float m_MoveSpeed = 3.5f ;
13
13
14
14
private void Update ( )
15
15
{
16
- if ( ! NetworkManager . Singleton . IsServer ) return ;
16
+ if ( ! IsServer ) return ;
17
17
18
18
if ( transform . position . x > k_YBoundary )
19
19
{
20
- if ( NetworkManager . Singleton . IsServer ) Destroy ( gameObject ) ;
20
+ if ( IsServer ) NetworkObject . Despawn ( ) ;
21
21
return ;
22
22
}
23
23
You can’t perform that action at this time.
0 commit comments