Hi, I’d like to create a target system like in classic mmorpg.
When I Left click on an enemy, it save it as a Target. (with an arrow on his head)
When I click on a spell, the spell go to my current target.
Actually I try to do the target script.
I have this script for create the arrow on my enemy’s head
But I have the problem "Cannot convert ‘UnityEngine.GameObject’ to ‘UnityEngine.Transform’.
"
And how this arrow can follow my enemy ?
var hit: RaycastHit;
var ray;
private var target : Transform;
var targetScript : Target;
function Update()
{
CheckClick();
}
function CheckClick()
{
if (Input.GetButtonDown("Jump") ||Input.GetButtonDown("Fire1"))
{
Debug.Log("space");
if (Physics.Raycast(ray, hit, 100))
{
if (hit.collider.tag == "Enemy")
{
target = hit.collider.gameObject;
var posetarget = Instantiate(target, transform.position, Quaternion.identity);
targetScript = posetarget.GetComponent(Target);
Counter=0;
}
}
}
}