I want to make a non-monobehaviour class that casts a ray from each object that uses an instance of the class:
#pragma strict
class TEST1
{
var object : Transform;
var hit : RaycastHit;
var distance : int = 10;
var origin : Vector3;
function TEST1 (obj : Transform)
{
object = obj;
origin = object.position;
}
function Update()
{
Physics.Raycast(origin, Vector3(0,10,0), hit,distance);
{
if(hit.transform.tag == "a")
{
print("a");
}
}
Debug.DrawRay(origin,Vector3(0,10,0),Color.red);
}
}
The class recieves the transform of an object and uses it co cast a ray from the objects position to a Vector3 position;
If I use it as a monobehaviour class (class TEST1 extends MonoBehaviour) and attach the script to a gameObject it will work just fineā¦but I want to know if its possible to get the same results without it inheriting from MonoBehaviour.