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