Hi, im new to Unity 3d and just completed the VTC Getting started with Unity 3d tutorial set. I completed everything fine.
I now have a turret that can kill me, grenades and explosions etc.
Now im trying to create a script that will allow me to kill the turret with my grenades
Im using a raycast to check for collisions, and checking if any of the objects i hit are tagged "Turret", then i want to print it to the console screen so i know that my raycasts work before i make the turret lose health.
The problem is my raycasts are not working.
Here is my code
var target: Transform;
function update()
{
var hit : RaycastHit;
if(Physics.Raycast(transform.position, target.position))
{
if(hit.collider.gameObject.tag == "Turret")
{
print("hitting");
}
}
}
What is wrong
I have attached this script to my player, and the "target" is set to the turret.
Help would be greatfully apreciated.
Thanx :D