ronkrt

Untitled

Apr 28th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class PlayerTargeting : MonoBehaviour {
  6.    
  7.     public List<Transform> targets;
  8.    
  9.    
  10.     // Use this for initialization
  11.     void Start () {
  12.         targets = new List<Transform>();
  13.         AddAllEnemys();
  14.        
  15.     }
  16.    
  17.     public void AddAllEnemys()
  18.     {
  19.    
  20.         GameObject[] go = GameObject.FindGameObjectWithTag("Enemy");
  21.         foreach(GameObject enemy in go)
  22.             AddTarget(enemy.transform);
  23.        
  24.        
  25.     }
  26.    
  27.     public void AddTarget(Transform enemy)
  28.     {
  29.         targets.Add(enemy);
  30.        
  31.     }
  32.    
  33.     // Update is called once per frame
  34.     void Update () {
  35.    
  36.     }
  37. }
  38.  
  39.  
  40.  
  41. Assets/Scripts/PlayerScripts/PlayerTargeting.cs(20,30): error CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.GameObject[]'
Advertisement
Add Comment
Please, Sign In to add comment