HI,
and another Problem.
Right now i am trying to make an “Skill” for my warrior. When i hit a button, i want to create an Arrow Pre fab für each enemy that is on my world.
This works for me with
foreach (GameObject go in GameManager.spawnEnemys)
{
GameObject disc = Instantiate(discPreFab);
disc.transform.position = new Vector3(transform.position.x+10,transform.position.y+10,transform.position.z+10);
now comes the problem, how can i say my prefabs where they should move to? I want one Disc for each enemy.
Tryed
void Update()
{
SetTargets();
//while (i < targets.Length) // while seems not to work here
//{
// transform.position = Vector3.MoveTowards(transform.position, targets*.transform.position, 50);*
// i++;
//}
if(GameManager.spawnEnemys.Count > 0)
{
foreach (GameObject go in targets)
{
transform.position = Vector3.MoveTowards(transform.position, go.transform.position, 50);
//GameManager.spawnEnemys.Remove(go);
}
}
}
public GameObject[] targets;
public void SetTargets()
{
targets = GameManager.spawnEnemys.ToArray();
}
combination but like expected doenst work for me. Have many trouble with target setting, if anyone knows a good tutorial especialy for multitarget it would be great. But any Answer which i can test and try to understand would be great
Greetz Smokki