Jump to content

  • Log In with Google      Sign In   
  • Create Account


Inverness

Member Since 11 Sep 2010
Offline Last Active Apr 11 2013 08:59 PM
-----

Posts I've Made

In Topic: Unreal Networking design questions

17 February 2013 - 12:27 PM

You mention actors that exist already in the level. This isn't a concept that has really applied to me as yet, because I have not considered a scenario where I would want level actors that aren't added depending upon the client connected. Could you possibly elaborate? I saw mention in the Unreal source but I wasn't sure when this would be useful to me.

Actors that already exist on the client would be those that are added to a level in the editor, which both the server and client would have a copy of in Unreal games.

The question reliability was specific to Unreal (or Tribes) with net priority; I was asking if that is the correct understanding of their model. Out of order delivery was asking how Unreal handles it (although this is related to the typical "How do I order an unreliable protocol"! I wouldn't mind simply dropping out of order packets except when there are delta variables (e.g the difference vector between two velocities) for more precision, which require access to the last state. Additionally, this does not seem to be how Unreal handles it.

I recommend using RakNet if possible because it can handle reliability issues for you. Unreal compresses its vectors send sends the full value over the Internet, not a delta from the last state. This way the packet can be ignored if it arrives late or not at all.

My other vague question was about the age of variables. It seems as though there is no specific support for determining the time for which the attributes were valid. This is fine but for extrapolation where I need to know the age of the position and velocity vectors to be able to use EPIC. I think that It would make sense to be able to lookup past states at a particular game tick (a synchronised concept of time) so should I implement this within the replication system, so the networking layer has its packet sequence number and the replication also sends the game tick with the replicated data on top of that protocol?

Unreal handles player movement separately from the rest of its replication using RPC. See this section: http://udn.epicgames.com/Three/NetworkingOverview.html#Player Movement and Prediction
 

Let me add some explanation as to why I appear to be so concerned with premature optimisation. I aim at sixty frames per second game frame rate. That leaves 16ms for all processes to execute in. Assuming 1ms is used for the render pipeline on average, that leaves 15ms. That's a lot of time if you write good code, and typically you'll have a fraction of a ms per client. However, this scales geometrically (I believe) with connection of new game-observing clients, as they have to be sent all other actors. Therefore .2 ms may seem small, but when that starts growing with just the scraper logic that seems dangerous. This said, these numbers are merely demonstrating the idea and are not representative of the actual model and this is without relevancy checks.

This is why you need to be conservative in determining which actors in a game need to be replicated and how often they need to be replicated.

Seeing as you mentioned your own progress, do you allow any non-actor classes to use replication? or have them handle their own data (e.g the scoreboard, clock)

In Unreal, the score board would be send to the client in WorldInfo which is a special actor representing the game world. You could also simply not use replication for things like that.

Right now I have 3 modes of communication in my game:

Normal replication happens only between actors and 5 times per second. This is done reliably, but order is not guaranteed and older packets can be ignored by the client. Example:
public override void Serialize(DeltaSerializer s, IReplicaClient destination)
{
	base.Serialize(s, destination);

	s.Write(_collideTiles);
	s.Write(_collideActors);
	s.Write(_blockActors);
	s.Write(_layer);
}

public override void Deserialize(DeltaSerializer s, IReplicaClient source)
{
	base.Deserialize(s, source);

	s.ReadBoolean(ref _collideTiles);
	s.ReadBoolean(ref _collideActors);
	s.ReadBoolean(ref _blockActors);
	s.ReadSByte(ref _layer);
}
 
Event messages can be sent manually between actors, which is what I use for my complex things like player movement or updating the inventory of an actor. For movement, this is done for every game update, which means 30 times per second as opposed to 5 for normal replication.
private void MoveAutonomous(Vector2 delta)
{
	// Only call this on the client when it is autonomous
	Debug.Assert(Actor.Role == NetRole.Autonomous);

	Move(delta);
	Vector2 newPos = Actor.Position;

	// Save moves so we can replay them later if the server corrects us
	_savedMoves.AddLast(new SavedMove(delta, _time));

	// Tell the server to do the same move and confirm or correct our own
	NetOutgoingMessage message = CreateEventMessage(EventServerMove);
	message.Write(delta);
	message.Write(newPos);
	message.Write(_time);
	message.Write((byte)_direction);
	SendEvent(message, NetDeliveryMethod.UnreliableSequenced);
}
Player messages can be sent through through the player objects that represent clients in a game. The client only has its own local player object that can send to the server, but the server has one for each player logged in the game to communicate with its local counterpart.

My final question so far is should the server store the state of all actors every tick? I cannot think immediately of why it would save for replaying, but does Unreal store the "state" of each actor in a lookup by game time?  And if so, is it every game tick or every network tick? It seems now would be the time to think about how that would be done, not further down the line.
 
And thanks for the example source, I'm sure it will be very useful!!

For each combination of a client and an actor relevant to it Unreal stores the values previously sent to that client. Replication is done by comparing the current value in an actor to the last sent value for each connection. This happens during network ticks only.

In Topic: Unreal Networking design questions

15 February 2013 - 01:37 PM

Thanks Kylotan. 

 

Well, when I started looking at logic usage that started to be the largest factor. If you have 6 players and 100 Actors in total, thats 6 * 100 checks per update. Which is a lot if its dict checking etc. 

 

In terms of creating a new actor, what happens if a client joins after the actor is created? I'm used to just having some check on the other side to see if we have the player registered otherwise we create it. Would you suggest that when the server evaluates the replication for the new client it invokes a create function on the client? I'm not really wanting to add RPC functionality beyond the scope of the actors themselves (using directed methods mentioned before) so I would imagine the client would simply deduce if the actor existed and if not create it. The reason I asked this question was because I originally believed that the WorldInfo class did not derive from Actor and So I wondered what sort of black magic was taking place to match the instance on the server to the instance on the client. I think I shall let that wait for now.  (the replication of world info).

 

Another question about reliability. can I confirm that whenever a reliable packet is attempted to be sent to a peer, it stores it in a reliable buffer, and checks the ACK packets to see if it got there, else it will resend it. If there is not enough bandwidth, it will ramp up the netpriority until it forcibly enters the outgoing queue. How does this deal with out of order delivery? I've yet to notice any signficant packet loss in my experience, so I've never worried considerably about order of packets, but if you resend a packet it then creates an out of order sequence on the receiving end. Should I drop the packet but ACK its receipt?

 

Also, I updated my post above to reflect my evolving thought processes! I shall quote it here, if you would be as kind as to read it! smile.png

 

I'm also using Unreal's networking model as inspiration for my own project, though I'm using C# for it.

 

Anyhow, a few points:

 

Actor checking: I suggest adding actors that could possibly be replicated (that aren't already provided by the level itself) to a separate list to be checked. You would further eliminate unnecessary checks by allowing actors to specify a replication rate so less important actors need not use as many resources.

 

And yes, if a client joins, the server would evaluate replication for that client and send it any actors that are relevant to it and they have not already been replicated to it.

 

As for reliability, I am using the Lidgren library for C# and used reliable sequenced delivery so packets always arrive but old packets are dropped in favor of newer ones.

 

As for Unreal networking attributes, bNetDirty is set whenever a property is set on an object in UnrealScript, it is a helper variable so you can skip replication if its false. bNetOwner is true when the client you're replicating to owns that actor, and bNetInitial is true when it is the first time you're replicating so you can send variables that only need to be sent once.

 

My current source code is available, it might be of some help or it might confuse you. tongue.png ReplicaManager handles replicating my actors through the IReplica interface. And you can look at my MovementBehavior component to see how player movement is handled. I just copied how Unreal did it in that case.


In Topic: How to start Network Programming?

01 February 2013 - 02:07 PM

Considering I'm already pretty proficient with C++, for learning networking, I looked at existing documentation and code for engines like Source, Doom 3, and UDK. They were really helpful in understanding how I would design my game architecture for networking and the different ways that are possible. UDK's documentation on its networking is extensive, and Valve has a developer wiki with information about how they handle networking.

 

Sending messages between servers is very easy depending on what kind of library you use, such as RakNet.

 

Unfortunately I can't really point you towards a specific book or tutorial since I never used one myself.


In Topic: Deploy an SDL game using Visual C++ 2010 Express

11 September 2010 - 02:28 AM

Quote:
Original post by tgashby
There's got to be a way to package it without dealing with that Visual C++ Redistributable...

Can I just compile it in the console or something and include the dlls?
With Visual C++ 10, you can simply include the runtime DLLs in the same folder as your executable and it will run. In previous versions, a private assembly was the only way to do this, but that is no longer necessary.

PARTNERS