Network fixes 2

This commit is contained in:
sebastianhampel1 2023-06-15 13:03:27 -04:00
parent 1030fd2fb9
commit 2bb8baa23c
4 changed files with 17 additions and 10 deletions

View File

@ -1,3 +1,4 @@
using FishNet.Object;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -46,7 +47,9 @@ namespace Item
isEnabled = true; isEnabled = true;
} }
public abstract bool Interact(); public abstract bool Interact();
[ServerRpc]
public abstract bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent); public abstract bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent);
protected void BaseAwake() protected void BaseAwake()

View File

@ -138,7 +138,7 @@ namespace Item
shootLight.gameObject.SetActive(true); shootLight.gameObject.SetActive(true);
// var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); // var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
InstanceFinder.ServerManager.Spawn(projectile); //var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); InstanceFinder.ServerManager.Spawn(projectile); //var projectile = Instantiate(projectilePrefab, bulletSpawnPoint);
//InstanceFinder.ServerManager.Spawn(projectile); //InstanceFinder.ServerManager.Spawn(projectile);

View File

@ -1,3 +1,4 @@
using FishNet.Object;
using UnityEngine; using UnityEngine;
namespace Player namespace Player
@ -46,7 +47,7 @@ namespace Player
timeSinceLastShot -= Time.deltaTime; timeSinceLastShot -= Time.deltaTime;
} }
[ServerRpc]
public void ShotFired() public void ShotFired()
{ {
timeSinceLastShot = shootNoiseDuration; timeSinceLastShot = shootNoiseDuration;

View File

@ -198,14 +198,17 @@ public class PlayerInteractionHandler : NetworkBehaviour
if (Input.GetButtonDown("Fire3")&&inputEnbaled) if (Input.GetButtonDown("Fire3")&&inputEnbaled)
if (!IsCarrying) if (!IsCarrying)
{ {
if(!IsServer)
SwitchWeaponMode(); SwitchWeaponMode();
GunEnabled = !GunEnabled; if (!IsServer) {
if (!GunEnabled) GunEnabled = !GunEnabled;
pistol.Disable(); if (!GunEnabled)
pistol.gameObject.SetActive(GunEnabled); pistol.Disable();
if (GunEnabled) pistol.gameObject.SetActive(GunEnabled);
pistol.Enable(); if (GunEnabled)
pistol.Enable();
}
} }
if (GunEnabled) if (GunEnabled)