Skip to content

Commit

Permalink
fix: welder in hand needed
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Sep 24, 2024
1 parent e61459b commit 0899443
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Assets/Scenes/Reparation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -13366,6 +13366,10 @@ PrefabInstance:
propertyPath: m_Name
value: FirstPersonController
objectReference: {fileID: 0}
- target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: welder
value:
objectReference: {fileID: 1128651451}
- target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: fixSound
value:
Expand Down Expand Up @@ -18616,6 +18620,7 @@ MonoBehaviour:
welderPrefab: {fileID: 1071434719}
rayDistance: 100
playerCamera: {fileID: 0}
_welderInHand: 0
--- !u!4 &1130256303 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -5819118886272102141, guid: e0f672a015f8fee418afd70dfd718f0d, type: 3}
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/FixLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class FixLogic : MonoBehaviour
public AudioSource audioSource;
public AudioClip weldingSound;
public GameObject welderParticles;
public Welder welder;

private bool _isOverlapping;
private GameObject _currentLeak;
Expand Down Expand Up @@ -37,7 +38,14 @@ private void OnTriggerExit(Collider other)

private void Update()
{
if (welder != null && !welder.welderInHand)
{
Debug.Log("Welder not in hand. Cannot fix leaks.");
return;
}

if (!_isOverlapping || !Input.GetKey(KeyCode.F) || _isFixing) return;

StartCoroutine(FixLeak());
audioSource.PlayOneShot(weldingSound);
welderParticles.SetActive(true);
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/Welder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Welder : MonoBehaviour
public float rayDistance = 3f;
public Camera playerCamera;

private bool _welderInHand;
public bool welderInHand;

private void Start()
{
Expand Down Expand Up @@ -43,8 +43,8 @@ private void TryPickUpWelder()

hit.collider.gameObject.SetActive(false);

if (_welderInHand) return;
if (welderInHand) return;
welderPrefab.SetActive(true);
_welderInHand = true;
welderInHand = true;
}
}

0 comments on commit 0899443

Please sign in to comment.