Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Error CS1502 and 1503

$
0
0
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 > map = new List>(); List players = new List(); int currentPlayerIndex = 0; // Use this for initialization void Start () { generateMap (); generatePlayers (); } // Update is called once per frame void Update () { } void generateMap() { map = new List> (); for (int i = 0; i < mapSize; i++) { List row = new List (); 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.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 (); 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 (); players.Add(player); } } Does anyone know what I might be doing wrong?

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>