muveso / Unity-Detection-Sensor

Object detection and optimized raycast system for Unity3D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detection Sensor For Unity

Unity License: MIT

Buy Me A Coffee

4

The Detection Sensor provides the basic functionality required for visual object detection. It wraps a sensor and exposes a ray list, to which you can use for raycast. You can instantiate and assign the sensor yourself.

Simple Usage

Create a gameobject and attach DetectionSensor component :

  • Script automatically add visual components for editor.
  • Adjust vertical and horizontal ray count.
  • Adjust ray positions on scene.

1

DetectionSensor will also simulate scene :


7

You can use your custom scripts with DetectionSensor :

[SerializeField] public DetectionSensor detectionSensor;
private DetectionRay[] _sensorRays;

private void Start()
{
    _sensorRays = detectionSensor.Rays;
}

private void FixedUpdate()
{
    for (var i = 0; i < _sensorRays.Length; i++)
    {
        var ray = _sensorRays[i];
        if (Physics.Raycast(ray.Ray))
        {
            Debug.Log("Hit!");
        }
    }
}

Unity Package

You can add the code directly to the project:

  1. Clone the repo or download the latest release.
  2. Add the UnityDetectionSensor folder to your Unity project or import the .unitypackage

Contact : sefa@muveso.com

About

Object detection and optimized raycast system for Unity3D

License:MIT License


Languages

Language:C# 100.0%