- Home /
targetting dont work
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public playerTarget Transform;
public pa PlayerAttack = GetComponent("PlayerAttack");
//empty RaycastHit object which raycast puts the hit details into
public hit RaycastHit;
//ray shooting out of the camera from where the mouse is
public ray Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
void Update() {
//check if the left mouse has been pressed down this frame
if (Input.GetMouseButtonUp(0)) {
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);
playerTarget = hit.collider.transform;
Debug.Log("PlayerTarget Successfully changed");
pa.target = playerTarget;
}
else{
Debug.Log(hit.collider.name + " no tag");
}
}
}
}
}
it dont work so pls help
im work in c# not java scipt
Comment
What about it doesn't work? Does it throw an error? Does it do anything? Does it even compile?
Just pasting a wall of code and stating it doesn't work won't get you anywhere.
Also please format it correctly.