mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-09-11 08:17:01 +00:00
38 lines
851 B
C#
38 lines
851 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Interaction : MonoBehaviour
|
|
{
|
|
public Transform detectionPoint;
|
|
public float radius = 3f;
|
|
public LayerMask detectLayer;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
bool InteractInput() {
|
|
if(Input.GetKeyDown(KeyCode.E))
|
|
Debug.Log("input");
|
|
return true;
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(DetectObject()) {
|
|
if(InteractInput()) {
|
|
Debug.Log("interacted");
|
|
}
|
|
}
|
|
}
|
|
|
|
bool DetectObject() {
|
|
if(Physics2D.OverlapCircle(detectionPoint.position, radius, detectLayer))
|
|
Debug.Log("detected");
|
|
return false;
|
|
}
|
|
}
|