Author Topic: Adding AI players to the player list  (Read 2143 times)

DoomSamurai

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Adding AI players to the player list
« on: July 27, 2013, 09:27:15 PM »
Hi!

I have a PlayerAI class that inherits from TNet.Player. I'm trying to add PlayerAI objects to the player list.


Player aiPlayer = new PlayerAI("playerAIName");
TNManager.players.Add(aiPlayer);


Now if I do this :

 IEnumerator<Player> e = TNManager.players.GetEnumerator();
            while (e.MoveNext())
            {
                Debug.Log(e.Current.id + " " + e.Current.name);
            }

It works fine! But if I try TNManager.getPlayer(id), it returns me a null reference.


Am I wrong in trying to add my AIs as Player objects in TNManager?


Thanks for your time!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding AI players to the player list
« Reply #1 on: July 27, 2013, 10:19:45 PM »
TNet works with TNet.Player, not "PlayerAI". You can't just derive from it. If you really need to extend it, modify the TNet.Player class directly.

And no, I don't really see why you would be adding your own players to the TNManager like that to begin with. That list is used to keep track of who's in a channel.