Tanoda
FingerCollisionDetection.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5public class FingerCollisionDetection : MonoBehaviour
6{
7 AudioSource audioSource;
8 public AudioClip success;
9 bool raycast = false;
10 // Start is called before the first frame update
11 void Start()
12 {
13
14 }
15
16 // Update is called once per frame
17 void Update()
18 {
19 RaycastHit hit;
20 var origin = transform.position;
21 var direction = -transform.forward;
22 if (Physics.Raycast(origin, direction, out hit, 0.02f) && hit.collider.gameObject.GetComponent<MeshRenderer>() && hit.collider.gameObject.GetComponent<MeshCollider>())
23 {
24 raycast = true;
25 }
26 else
27 {
28 raycast=false;
29 }
30 }
31
32 internal bool raycastFinger()
33 {
34 return raycast;
35 }
36}