Initial Commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class point_detector : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private bool isInside = false;
|
||||
//vecor to save all entery and exit points
|
||||
private Vector3 entrypoint;
|
||||
private Vector3 exitpoint;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.name=="tissue" ) // Make sure to set an appropriate tag for your cube
|
||||
{
|
||||
|
||||
//Debug.Log("Needle entered the cube.");
|
||||
//find the coordonates of the entering point
|
||||
entrypoint = other.ClosestPointOnBounds(transform.position);
|
||||
//Debug.Log("Point: " + entrypoint);
|
||||
//save all entering points in a vector
|
||||
|
||||
// Perform actions when the needle enters the cube
|
||||
// Example: Record entry point or start a suture action
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.gameObject.name=="tissue") // Make sure to set an appropriate tag for your cube
|
||||
{
|
||||
|
||||
exitpoint = other.ClosestPointOnBounds(transform.position);
|
||||
//Debug.Log("Point: " + exitpoint);
|
||||
// Perform actions when the needle exits the cube
|
||||
// Example: Record exit point or finish the suture action
|
||||
var VectorPair=(entrypoint,exitpoint);
|
||||
Debug.Log("Entry-Exit Vector: " + VectorPair);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user