Authoritative Server "Starting Point" on the Asset Store?

Hey Gang -

I wanted the opinion of the community on my latest project, and was hoping to get some feedback. I’ve written a demo project that uses Unity’s builtin networking. The design is 100% Authoritative, and seems to perform pretty well so far. The project is an excellent starting point for FPS games, and I can quickly convert it to a Third Person demo as well.

Current Features:

  • Three weapons:
    — 1. The first weapon is a rigidbody based projectile that moves at high speed and does raycasting to help detect collisions
    — 2. The second weapon is also rigidbody based, but moves much slower and does explosive damage (grenade launcher)
    — 3. The third weapon is entirely raycast based, to simulate extremely fast moving projectiles
  • Death and respawn functionality
  • Fully networked translation controls (movement, rotation, jumping and can be converted to control turrets as well)
  • Server-side “death” zones for falling damage
  • Simple, effective peer-to-peer connectivity and network connection testing
  • Client side prediction/interpolation
  • Rigidbody physics
  • Destructible static objects
  • Networked Material changes
  • Simple, easy to follow system for adding additional content to the authoritative server and clients
  • Fully commented code and documentation (still being written)

Possible Future Additions:

  • Scoring
  • Item Pickup
  • Loot Spawning
  • Statistical Tracking
  • AI implementation of Behave and UnitySteer in the Authoritative model

Now I realize that there are tutorials freely available that cover some of this content, however I do not believe any tutorial covers it as in-depth as my demo/starting point will.

The initial demo can be seen at the link at the end of this initial post. Please remember that this is still under heavy testing, therefore if you notice any bugs, I’d be grateful if you could post here. If you have any other comments or suggestions, I’m all ears! Basically, I’m wondering if anyone would find this useful for your own purposes and if you’d be willing to pay for such a thing? Thanks!

Link to Authoritative Server Demo

Controls:
Press 1, 2, or 3 to change between weapons
WASD for Movement
Mouse Axis for rotation
Spacebar to jump
LMB to fire active weapon
Press/Hold Escape to release the mouse

QUICK NOTE - I realize the first weapon (fast moving rigidbody projectile) is a little buggy, especially in regards to where it spawns the explosion. This is a basic problem for all rigidbodies that move quickly. I have written some code to assist the collision detection but it needs more work. I plan on updating the starting point project as I resolve these issues.

I think its great,fire a lot of grenades at the ground in front of you and watch the new year fireworks display in the sky :smile:.

On a more sensible note, yes i would by it.

Dave

@Dave
Thanks! Glad you liked what you saw!

I think i have a decent grasp on unity’s networking, but I would definitely buy it just to see how someone else would handle it, and I only did a couple things authoritatively in my prototype.

A few questions though:

Does you project use the unity master server at all?
Are you manually allocating view ids?
Are you doing EVERYTHING authoritatively?

@legend411

To answer your questions-
1 - For the first version, it does not. However, I can incorporate a GUI for the master server rather easily as the project expands

2 - I am not manually allocating view ids. I chose to go a simpler route and use Network.Instantiate ( it’s always called on the server, no exceptions ). However, I also have a buffer cleanup process that removes objects on specific network view groups. For example, all projectiles are spawned to group 100, and every 10 seconds, the server eradicates all buffered calls to that group (as no projectile lives longer than 10 seconds anyway) simply by scheduling calls to Network.RemoveRPCsInGroup (weaponNetViewID); Dynamically spawned, static objects that have short life spans (explosions, most particle effects, etc) are spawned using unbuffered RPCs and Object.Instantiate. Again this process is initiated by the server, but the action of instantiating is “pushed” down to the client as a local only object.

3 - Yessir, everything is authoritative. Even physic calculations are performed on the server and streamed to clients. Clients use interpolation/extrapolation to smooth the movement for all rigidbodies (quite similar to the NetworkRigidbody script). Of course, the number of physics objects should be limited so bandwidth isn’t throttled. In addition tasks such as weapon changing, material changing, ammo selection are controlled on the server. I really wanted to take this project to an extreme so that people could get a very good idea of how it works (my interpretation at least). To use my project in an MMO would not be advisable, but to use it for a 32 player death match game … sure, that should work very well :slight_smile:

I would probably buy it just for the insight into network groups alone… currently I have a cooperative action-rpg prototype functioning, and I made it lobby-based (everyone goes to the lobby, the the host launches the game), just because I wanted to force everyone to join at the same time so I didn’t have to deal with cleaning up Network.Instantiated NPC enemies that were already killed before new players connect.

I tried instantiating and destroying them with buffered RPC’s and controlling them authoritatively, my game flips out for some reason if I don’t Network.Instantiate them.

@legend411

If destroying the objects is causing you fits, you could try disabling them instead when they are killed in-game. That’s one method that has worked for me very well in the past. Basically you have to deactivate the AI routines (whichever script controls the AI), disable the renderer, and then change the colliders to triggers. Here’s an example: The script below is called whenever damage is dealt to a player or NPC, and it occurs on the server only. If a death condition is detected, the server calls the deactivate function locally as well as an RPC call to the deactivate function on all clients. Notice that the RPC call is buffered too.

// ApplyDamage is only called on the server!

public var _Collider : Collider[];
public var _Renderer : Renderer;

        public void ApplyDamage( string[] info ) {
		float damage= (float)Convert.ToDouble(info[0]);
		string killerNam= info[1];
		HitPoints -=  damage;
		if(HitPoints <= 0) {
			networkView.RPC("DeactivateMe", RPCMode.OthersBuffered, myTransform.position);
			DeactivateMe(myTransform.position);
			return;
		}
		networkView.RPC("SetHP",RPCMode.Others, HitPoints);
	}
	
	[RPC]
	void DeactivateMe(Vector3 pos) {
		Instantiate(explosionPrefab, pos, Quaternion.identity);
		_Renderer.enabled = false;
		
		foreach(Collider c in _Collider)
			c.isTrigger = true;
	}

Wrapping up documentation! Submission to Asset Store should be very soon!

Nice, I’d be interested in this as well. I can’t seem to try your web player though, it says “Public IP address but server not initialized…etc”

@Zombie - try changing the IP address to 127.0.0.1

If that doesn’t work, try using a different port before pressing “Start Server”.