err help

i have come to an err and was wondering if you guys could help me

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Targetting : MonoBehaviour {
public List targets;

// Use this for initialization
void Start () {
targets = new List();

AddAllEnemies();
}

public void AddAllEnemies()
{
GameObject[ ] go = GameObject.FindGameObjectsWithTag(“Enemy”);

foreach(GameObject enemy in go)
AddTarget(enemy,transform);
}

public void AddTarget(Transform enemy)
{
targets.Add(enemy);
}

// Update is called once per frame
void Update () {

}
}

is what i have and i have an err that says
Assets/MoreScripts/Targetting.cs(20,25): error CS1501: No overload for method AddTarget' takes 2’ arguments

i have know idea what that means if you could help me that would be great

thanks in advance

the function needs 1 param and you give 2 :

public void AddTarget(Transform enemy) ← 1 param

AddTarget(enemy,transform); ← 2 params
Please also use the tags when you post code.

sadly, the error says it all…

AddTarget(enemy,transform);

…is calling for a method which takes two variables. (enemy and transform)

Your current method only takes one. A Transform by the name of “enemy”

I assume you mean to call it as…

AddTarget(enemy.transform);

(note the period between enemy and transform. :wink: )

Change this line:

AddTarget(enemy,transform);

To this line:

AddTarget(enemy.transform);

Edit: Beat me to it, that’ll teach me to read a cached copy. :slight_smile:

This. :wink:

+1 to you sir.

-1 to OP

:slight_smile:

You obviously meant This :stuck_out_tongue:

Both awesome articles!