Im trying to target something using js
PlayerAttack script is CS could that be the problem?
public var target : Transform;
function Update()
{
//check if the left mouse has been pressed down this frame
if (Input.GetMouseButtonUp(0))
{
//empty RaycastHit object which raycast puts the hit details into
var hit : RaycastHit;
//ray shooting out of the camera from where the mouse is
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, hit))
{
if (hit.collider.gameObject.CompareTag("Enemy")){
//print out the name if the raycast hits something
Debug.Log(hit.collider.name);
target = hit.collider.transform;
PlayerAttack pa = (PlayerAttack)GetComponent("PlayerAttack");
pa.target = target.gameObject;
}
else
{
Debug.Log(hit.collider.name + " no tag");
}
}
}
}