Hello. I have this script:
(Physics.Raycast (ray, out hit, 200))
{
Transform ObjectHit = hit.transform as Transform;
if (hit.collider.tag == "enemy")
{
//some code
}
}
With this I want to touch game object. And it is working, but the problem is that I have object of type “Transform”, not “GameObject” and that is not working. I want to apply that script to object that is created with this script
Transform clone;
clone = Instantiate (projectile, spawnPosition.position, spawnPosition.rotation) as Transform;
As you can see it’s “Transform”, not “GameObject” so this doesn’t work. Any way to get it work?