- Home /
No Overload for x?
I've been following the hack and slash tutorial, found here:http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
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);
}
}
}}
Answer by BiG · Feb 02, 2012 at 09:14 AM
I think that this line:
Vector3 dir = (target.transform.position = Transform.position).normalized;
should be:
Vector3 dir = (target.transform.position - Transform.position).normalized;
(There's a "-" instead that an "=").
Your answer
![](https://koobas.hobune.stream/wayback/20220613063649im_/https://answers.unity.com/themes/thub/images/avi.jpg)