Who shot that? Networking Projectiles.

Who gets the points?

In my previous article I talked about how you can achieve better performance by creating projectiles locally when compared with creating a server instance and keeping them synchronised with the clients. But what happens when the projectile actually hits something, who gets the points associated with killing the enemy?

Projectile Ownership

When the ship fires a bullet (a projectile) it previously called the Launch method of the bullet. Now it has changed to also pass in the Network Id of the ship that fired it. The bullet has an owner that we can trace back to ship and therefore the player.

Player Score UI

When the ship is created AND we are the Client then we tell that client’s UI Manager the network Id of the ship.

When the UI Manager is asked to increase the score it compares the owner of the projectile and only increases the score if there is a match.

Therefore each player can be attributed the score value of the enemy they hit.

What next?

Unity, VR, Enterprise and .Net Developer