Finalized for game jam submission
Lots of bugfixes New tasks
This commit is contained in:
49
Assets/Scripts/Items/USB.cs
Normal file
49
Assets/Scripts/Items/USB.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class USB : MonoBehaviour
|
||||
{
|
||||
public float interactionDistance = 10;
|
||||
public GameObject hint;
|
||||
private GameManager gameManager;
|
||||
private Renderer renderer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||
renderer = gameObject.GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
hint.SetActive(false);
|
||||
if (renderer.isVisible)
|
||||
{
|
||||
if(Vector3.Distance(transform.position, gameManager.player.transform.position) <= interactionDistance)
|
||||
{
|
||||
hint.SetActive(true);
|
||||
hint.transform.rotation = Quaternion.LookRotation(hint.transform.position - gameManager.playerCamera.transform.position );
|
||||
|
||||
if (Keyboard.current.eKey.wasPressedThisFrame)
|
||||
{
|
||||
gameManager.playerHasUSB = true;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawWireSphere(transform.position, interactionDistance);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user