I’ve been following the hack and slash tutorial, found here:BurgzergArcade.com is for sale | HugeDomains
I am having multiple errors, like:
UnityEngine.Vector3 does not contain a definition for transform
No overload for method “Distance” takes ‘1’ arguments
and more, help would be greatly appreciated.
Here is my code: (Sorry cant get samples to work)
using UnityEngine;
using System.Collections;
public class Enemy : MonoBehaviour {
public GameObject target;
public float attackTimer;
public float coolDown;
// Use this for initialization
void Start () {
attackTimer = 0;
coolDown = 2.0f;
}
// Update is called once per frame
void Update () {
if(attackTimer > 0)
attackTimer -= Time.deltaTime;
if(attackTimer < 0)
attackTimer= 0;
if(attackTimer == 0){
Attack();
attackTimer = coolDown;
}
}
private void Attack(){
float distance = Vector3.Distance (target.transform.position. transform.position);
Vector3 dir = (target.transform.position = Transform.position).normalized;
float direction = Vector3.Dot(dir, transform,forward);
if (distance <2.5f){
if (direction > 0) {
PlayerHealth eh= (PlayerHealth) target.GetComponent("PlayerHeal");
eh.AddjustCurrentHealth(-10);
}
}
}}