RPC in FPS with Photon PUN 2 in Unity (Part 10)
How to make a Multiplayer Video Game
For this tutorial lesson, on how to make a multiplayer game in Unity using the Photon 2 plugin we will be using the RPC functions we have learned about to make a basic first-person shooter control that will sync across the network. This tutorial will teach you how to use the RPC function of the Photon 2 plugin in other scenarios. After this lesson, you should have a better understanding of RPC function and what they can do as well when to use them. You will also learn how to take any game machinic and make it work in a multiplayer game.
SUBSCRIBE for regular Video Game making videos:
We will begin by creating variables in our Avatar setup script for the first one will be player health and the next one will be player damage. We will then create a new C# script called Avatar Combat. In this script, we will create some new variables. We will then initialize these variables. We will then create a shooting function and we will use Raycast to do this. We first want to check for player input and then we will create our Raycast. If the Raycast hit another player then we want to remove health from that player. We will then save our C# script and go back to Unity.
In Unity, we will create and add a new camera to our player avatar object. We then need to attach our new scripts to their respective object and set the variables.
We will then go back to our Avatar combat script and we will turn this script into a script that will work across the network. We will do this by creating an RPC function that will synchronize the player’s health across the network when the player has been shot.
If you followed along with the video then you should now have a working basic FPS controller that networks the player’s health when shot.
Xem thêm bài viết khác: https://uwallpaperhd.com/game/