Support => TNet 3 Support => Topic started by: wolkovik on December 07, 2013, 12:20:43 PM
Title: TNet and AI
Post by: wolkovik on December 07, 2013, 12:20:43 PM
Hey guys I've been reading a lot of topics but I didnt find any info about how to manage AI in unity with TNet. Can somebody please direct me in a right direction about AI management? If AI is calculated at each connected client and then synched (i dont know about this option - what if a client tempor. disconnects...?) or somehow built in in the launched TNET server or something like that?
Title: Re: TNet and AI
Post by: ArenMook on December 07, 2013, 04:16:38 PM
If you normally do AI in some Update() function of a script attached to your NPCs, make the script derive from TNBehaviour instead of MonoBehaviour, attach a TNObject to work with like you would with any sync'd object, and in the Update function exit early if (!tno.isMine).
Then instead of setting local values using your AI logic, send them to everyone using RFC calls.
Title: Re: TNet and AI
Post by: wolkovik on December 07, 2013, 04:51:34 PM
Ok, it seems logical. Thanks :)
Title: Re: TNet and AI
Post by: CastorHolyday on January 14, 2014, 03:52:03 PM
"and in the Update function exit early if (!tno.isMine)."
means if(tno.isMine == false) { //dont do stuff inside unless tno isMine returns true } ?
I don't understand this part, I mean why ! the AI is supposed to belong to none but in the same time everyone can interact with them, a quick explanation with a simple exemple say like from StarCraft Online with 2 players & 1 AI would be welcomed, if you don't mind.
Thanks.
Title: Re: TNet and AI
Post by: ArenMook on January 14, 2014, 07:00:10 PM
Exiting out early means this:
void Update()
{
if(!tno.isMine)return;
// ...do actual game logic, including AI logic
}
Title: Re: TNet and AI
Post by: CastorHolyday on January 14, 2014, 07:12:27 PM
But ! which script is that ? a special script for the AI on the AI Object or on the player script I'm confused.
I think i'm thinking server Autho while you are talking about a p2p implementation.
Title: Re: TNet and AI
Post by: ArenMook on January 14, 2014, 10:06:55 PM
The script where AI logic happens. It should only happen on one of the players -- whoever owns the object.
Title: Re: TNet and AI
Post by: CastorHolyday on January 15, 2014, 05:07:49 AM