private void CmdServerUpdate(bool keyPressed) { if (!isServer || !keyPressed) { return; } GameObject bulletInstance = Instantiate(bulletPrefab, transform.position, Quaternion.identity); PowerUpAction powerUpAction = _playerNetworkedPowerUpController.GetPowerUp(); if (powerUpAction) { if (powerUpAction.powerUp.powerUpType == PowerUpType.Modifier && powerUpAction.IsPowerUpActive()) { powerUpAction.ModifyGameObject(bulletInstance); } } bulletInstance.GetComponent <Rigidbody2D>().velocity = transform.up * launchVelocity; NetworkServer.Spawn(bulletInstance); }
private void OnTriggerEnter2D(Collider2D other) { if (!isServer) { return; } if (other.gameObject.layer != 9) { return; } PowerUpAction powerUpAction = _playerNetworkedPowerUpController.GetPowerUp(); if (powerUpAction != null) { if (powerUpAction.powerUp.powerUpType == PowerUpType.Defence && powerUpAction.IsPowerUpActive()) { return; } } _playerNetworkedDestroy.DestroyPlayer(); }