sending multiple transforms from a scene?

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

sending multiple transforms from a scene?

Postby foxter888 » 01 Aug 2012, 19:12

hi good afternoon, here are some questions in which i might need some guidance and see if it would help me with optimizations,
i got AI working so far for my fps game project anyhow the way i'm aproaching it is whoever made the room meaning the owner is going to instantiate the main AI that will do the collision checking and sensors and even the pathfinding.

now they all are sending their transforms out and so far seems to run fine but i'm sending them like how i would do normally with the player, one question would be isn't it better gather all the info and sent it as one big array? if it isn't why not? and where to go about learning how?

other weird things i get is when reviving the player sometimes randomly the physics in unity get's messed up like all the sudden the player stops recieving or registering collisions or getting stuck. i know that some would say to check my movement scripts and so on but nothing is even touching those scripts nor even overriding the localplayer position or anything. seems like i get a bit of clogging randomly.
get to work you slacker!!!
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 06 Aug 2012, 19:18

bump, no answers yet lol
get to work you slacker!!!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: sending multiple transforms from a scene?

Postby Lapo » 07 Aug 2012, 08:23

the way i'm aproaching it is whoever made the room meaning the owner is going to instantiate the main AI that will do the collision checking and sensors and even the pathfinding.

So you are saying the game logic will run on the client side?
Actually it's not a good idea. Especially in action games the server must act as the "brain" of the game and keep the game state in synch with all players.
Did you take a look at our Unity FPS example and whitepaper? There's a lot of information and tips in there.
http://docs2x.smartfoxserver.com/ExamplesUnity/fps
Lapo
--
gotoAndPlay()
...addicted to flash games
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 09 Aug 2012, 04:08

honestly i'm pretty confused when it comes trying to do the AI server side, and the other thing to would be me having to know how to do path finding server side, so that's why i went with the setup as having a client being a controller and no one seems to be able to help nor tutorials, so i'm going to have to keep doing it the way i am until i'm able to learn somehow about it.

i need more support mainly
get to work you slacker!!!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: sending multiple transforms from a scene?

Postby Lapo » 09 Aug 2012, 08:03

You won't find much help in that regards because that's not the right way of doing it, I am sorry.
If you want to learn how to create an action game take the Unity FPS example and it's accompanying tutorial. You can experiment with that code, check the server side AI and finally build your own prototype.

Take your time with it, nobody becomes a multiplayer guru overnight :)
Lapo

--

gotoAndPlay()

...addicted to flash games
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 09 Aug 2012, 12:09

i have been taking time to try to understand some concepts, the ones that never seem to work so well for me normally are class serialization, movement done by the network and full collision. and the tutorial it's not fully comented line by line the pdf just show somewhat of how the network is done it doesn't fully explains everything like some form of a vague tutorial.

yes we are able to understand some by checking both the server and client sources. still it doesn't explain the concepts fully. pretty much we have to copy and paste things in order to make things work rather than learning how to do it all from scratch.
get to work you slacker!!!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: sending multiple transforms from a scene?

Postby ThomasLund » 10 Aug 2012, 12:28

Sorry, but the tutorials are not made for line by line walk through. And its not going to be added either, as explaining all concepts of multiplayer game programming is a thick book. There are several good books on multiplayer game architecture available on Amazon - its NOT simple learning it all. Multiplayer is possible the most complex thing possible in game development.

Like Marco says - got to put logic on server if you want true authoritative server.

The FPS example will also only take you partly there, as its lacking a server side tick.

If you go full out server side, you need to implement a server tick system that every e.g. 100 ms processes incoming transforms, moves models in the simulated world, checks for collisions and returns an array of transforms to all clients.

Also client side you want to bundle up transforms (if you stick with your design of a "master client"). Should use an array of transforms that the server then distributes to everyone else.

Being on that path - DONT have physics on remote avatars. You cannot both have physics driven movement at the same time as a master client sending the transform and dictating where/how to place remote avatars. That defeats the purpose of a master client. The remote avatars should only be dumb static models really that mimick the animation.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 10 Aug 2012, 12:33

now about being able to get all transforms into a array or some form of collection so i could apply it to all rather than individually would this be a good aproach? and how would i go about it? i'm still new with learning to be able to send sfs array and any regular arrays that you could add to the smartfox object
get to work you slacker!!!
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 04 Sep 2012, 06:41

now are there any resources where i can learn what you guys mean by server tick? now before about the ai in which i planned to have one client being the main one seemed fine since the pathfinding and all that is done using unity, i know this is wrong in which the ideal way would be do almost everything server side, but it's not like there is a lot of places that comes with a manual about doing the full movement and so on in the server and collisions. i know the fps tutorial has some form of it in some areas. but it seems to lack a lot of explanations since it's not fully step by step.

now my main question would be how to go about sending the transforms in a array? does that means i have to do class serialization or something?
get to work you slacker!!!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: sending multiple transforms from a scene?

Postby ThomasLund » 27 Sep 2012, 10:26

Putting things into a single object and sending that is a very good approach.

Use the players sfs connection id as key.

Check the documentation and examples using SFSObject and SFSArray on how to embed things into something you can send in a single request to the server (or from server to clients).

Server tick - this is a scheduled piece of code on the server.

What you want to do is e.g.

Code: Select all

   public static int SERVER_TICK_TIME = 100;
   private ScheduledFuture<?> mainTickScheduler;

....
   @Override
   public void init() {
      mainTickScheduler = SmartFoxServer.getInstance().getTaskScheduler().scheduleAtFixedRate(new MainServerTick(this), SERVER_TICK_TIME, SERVER_TICK_TIME, TimeUnit.MILLISECONDS);
.....
}


and then have something like

Code: Select all

public class MainServerTick implements Runnable {
   private GameExtension gameExtension;

   public MainServerTick(GameExtension GameExtension) {
      this.gameExtension = GameExtension;
   }

   @Override
    public void run() {
      if (gameExtension.getParentRoom().getUserList().size() == 0) return;

      long startTime = System.currentTimeMillis();
      // Process incoming requests
      // Run through all dynamic objects and check collision
      // Update positions via movement
      // Send new position of everything changed
      // Send new status of everything changed

      for (IGameObject gameObject : gameExtension.getWorld().getGameObjects()) {
         gameObject.update();
      }

      gameExtension.getWorld().sendProjectileTransforms();

      long endTime = System.currentTimeMillis();

      if (endTime - startTime > GameExtension.SERVER_TICK_TIME) {
         gameExtension.trace("ERROR - time spend in tick longer than tick time");
      }
   }
}


Something like that runs on server and then updates positions of everything and sends out the updates to all clients
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Re: sending multiple transforms from a scene?

Postby foxter888 » 02 Oct 2012, 13:51

i apreciate the reply i'll look into it more when i can.
get to work you slacker!!!

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 19 guests