This is the Raycast Shooting script
#pragma strict
var hitMarker : Texture2D;
var par : Transform;
var TheDamage = 25;
var fireRate = 0.5;
private var lineTransform : Vector3;
private var startTransform : Vector3;
var isHitEnemy :boolean = false;
function FixedUpdate()
{
isHitEnemy = false;
}
function Update ()
{
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5));
if(Input.GetMouseButtonDown(0))
{
if (Physics.Raycast (ray, hit , 100))
{
var clone = Instantiate(par, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(clone.gameObject, 1);
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
if(hit.rigidbody)
{
if(hit.transform.tag == "Enemy")
{
isHitEnemy = true;
}
}
}
}
function OnGUI()
{
if(isHitEnemy ==true)
{
GUI.Label(Rect(Screen.width/2, Screen.height/2, 200, 200), hitMarker);
}
}
This is the cursor script
var mouse : Vector2;
var w : int = 32;
var h : int = 32;
var cursor : Texture2D;
function Start()
{
Cursor.visible = false;
}
function Update()
{
mouse = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
}
function OnGUI()
{
GUI.DrawTexture(new Rect(mouse.x - (w / 2), mouse.y - (h / 2), w, h), cursor);
}