Trying to add two player (objects) to a plane, but I keep getting these errors:
Assets/Scripts/GameManager.cs(46,25): error CS1502: The best overloaded method match for `System.Collections.Generic.List.Add(Player)’ has some invalid arguments
Assets/Scripts/GameManager.cs(46,25): error CS1503: Argument #1' cannot convert
UserPlayer’ expression to type `Player’
and it’s the same for 50,25.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GameManager : MonoBehaviour {
public GameObject TilePrefab;
public GameObject UserPlayerPrefab;
public int mapSize = 12;
List <List<Tile>> map = new List<List<Tile>>();
List <Player> players = new List<Player>();
int currentPlayerIndex = 0;
// Use this for initialization
void Start () {
generateMap ();
generatePlayers ();
}
// Update is called once per frame
void Update () {
}
void generateMap() {
map = new List<List<Tile>> ();
for (int i = 0; i < mapSize; i++) {
List <Tile> row = new List<Tile> ();
for (int j = 0; j < mapSize; j++) {
Tile tile = ((GameObject)Instantiate (TilePrefab, new Vector3 (i - Mathf.Floor (mapSize / 2), 0, -j + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<Tile> ();
tile.gridPosition = new Vector2(i, j);
row.Add (tile);
}
map.Add (row);
}
}
void generatePlayers() {
UserPlayer player;
player = ((GameObject)Instantiate (UserPlayerPrefab, new Vector3 (0 - Mathf.Floor (mapSize / 2), 0, -0 + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<UserPlayer> ();
players.Add(player);
player = ((GameObject)Instantiate (UserPlayerPrefab, new Vector3 ((mapSize-1) - Mathf.Floor (mapSize / 2), 0, -(mapSize-1) + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<UserPlayer> ();
players.Add(player);
}
}
Does anyone know what I might be doing wrong?