Update PlayerInteractionHandler.cs

This commit is contained in:
sebastianhampel1 2023-06-15 12:03:19 -04:00
parent c7591bbb67
commit f553471278

View File

@ -1,11 +1,13 @@
using System.Collections.Generic;
using UnityEngine;
using FishNet.Connection;
using FishNet.Object;
namespace Player
{
[RequireComponent(typeof(Collider))]
public class PlayerInteractionHandler : MonoBehaviour
public class PlayerInteractionHandler : NetworkBehaviour
{
public static PlayerInteractionHandler instance;
@ -27,6 +29,7 @@ public class PlayerInteractionHandler : MonoBehaviour
public bool isDead;
//Check if button down
private readonly AxisIsDown fireDown = new("Fire1");
private bool flashlightEnabled = true;
@ -48,6 +51,15 @@ public class PlayerInteractionHandler : MonoBehaviour
public Transform CarryingPos => carryingPos;
public override void OnStartClient()
{
base.OnStartClient();
if (!base.IsOwner)
{
this.enabled = false;
}
}
// Start is called before the first frame update
private void Start()
{
@ -61,6 +73,7 @@ public class PlayerInteractionHandler : MonoBehaviour
itemSelector = Item.ItemSelector.instance;
pistol.gameObject.SetActive(GunEnabled);
flashlightEnabled = flashlight.gameObject.activeSelf;
shift = GameObject.Find("CameraHidden").GetComponent<CameraShift>();
}