Author Topic: Neutral Network Objects  (Read 2631 times)

vzdemon

  • Guest
Neutral Network Objects
« on: April 20, 2013, 10:43:30 AM »
So i have this soccer game i want to make it into a multiplayer game. So i need the ball object to be neutral meaning that neither of the players will get true when calling TNManager.isThisMyObject in the ball script. basically i want none of the clients to control the object, i want then only to interact with it as if it is another player.

iByte

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Neutral Network Objects
« Reply #1 on: April 21, 2013, 01:07:18 AM »
Hi vzdemon, I was wondering how to handle the same requirement.

I was thinking of having two TNManagers for first player that joins a channel, so that there will be a silent player, that controls and owns non player specific objects.

I was going to give this a try but have not had a chance yet to see if this approach would if fact be possible or workable.

iByte

danreid70

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Neutral Network Objects
« Reply #2 on: April 21, 2013, 08:27:22 AM »
Why not just check for "TNManager.isHost" for any logic on the ball code? There will always be only one host in a channel, and if ball is synced, you could pick other public vars of the ball code so all other players could access them (via their network instantiated copy of the ball) but only host actually "owns" it, and makes final judgement in logic. If host player leaves game, another automatically becomes host and logic is then controlled by that player.

Was thinking more on this... You could synch a variable like "lastKickedByPlayer" and set that variable from each player's copy of the ball, and make sure variable can be synced by all. The host logic could then, for instance, check that variable if ball hits a "score" trigger, and you'd know which player made the final kick, and scored the point. Etc... This scoring logic would be done on whichever player is currently the host. A score object could be set with points and sync he'd by all, as well. That way it's always up to date on all players, and if host changes, whichever player becomes host still has most current data to work with for game logic.

Each player has exactly the same code, it's just that the scoring and main game control logic always has to check if it is host first before executing any of it.
« Last Edit: April 21, 2013, 08:41:05 AM by danreid70 »