Questions about creating a multiplayer FPS

Hi everyone

I’m planning on creating a simple FPS multiplayer game. By doing this, I hope to get a little more comfortable with UE4. Though, I have some questions about creating it since I don’t really know how it works.

First of all, should I use a projectile to represent bullets ? Or something totally different ? I know projectile could be used (since technically, it’s exactly what a bullet is) but I’d like to be sure.

Second thing, how would you handle the server thing ? It’s not supposed to be a 64 player game, just a bunch of friends, like maximum 10. Is it possible to have one of the players hosting the game directly on the client or do I have to create a server in addition to the client ?

Finally, how does a server work ? I didn’t find a lot of things about this. I think most of the actions should be processed by the server and not the player (to prevent cheating for example) but… how ? Is it something like "the client provides to the server the info about the player - keys pressed, mouse clicked… - then the server processes it and provides the client the info needed - position of the other players + current state of the character + state of the map - or am I totally wrong in the way it works ? Finally, what UE4 components should I use to do such a thing ?

Finally, is it possible to do this using Blueprints ? I saw you could do a lot of things, and I already succeeded in doing a lot of things using them, but I wonder, especially for the network part, if it would be possible, unless UE4 has some special components intended especially for this. And concerning the server… what should be done ? I mean, if it has to process the positions of the players, it has to be able to load and handle a map, but also projectiles and AIs. Should it be a game too ?

Thank you in advance

Hello ! I will do my best to answer you, all part are only in my opinion :wink:

First : Representing bullet depend of their speed : slow projectile may be mesh represented and should use projectile module, while fast projectile can use beam emitter and a “line trace”. (I use the second for my lasers weapons)

Second : if you build a Server version, it will be only a dedicated server, if you build a client, it will be a client only, if you build a standalone (the default one) it will be client/server in the same time. For 10 players, I think it can be done without dedicated server. (If you want a dedicated server : https://wiki.unrealengine.com/).

Third : Core function should be done by the server (using “run on server” event), and you can try if the caller is the server with “Has authority” node. For the caracteres, you should try the “replication” tutorial : https://docs.unrealengine.com/ Keep in mind that if players have the server too they can cheat easily (with RAM modifiers)

Finally : Blueprints do lot of things, but for networking its “limited”, if a function doesn’t exist, you will have to do it in c++, but if you want basic functions, all is already in BP.

Have fun with UE4 :wink:

Is it possible to have one of the players hosting the game directly on the client or do I have to create a server in addition to the client ?

What you could do is setup what is called a Listen Server. What a Listen Server does is allows you to be the Host while still playing the game on the same machine. Take Halo CE for example. You could go to the multiplayer screen and hit Host Server. It would then allow you to set up different options, you could then host the server and give the IP for your friends to join. That is called a Listen Server. You were the server, but you were also connected to your own server as a client. A dedicated server as the name implies is dedicated to only running the functions necessary for the server. While you could run a Dedicated server in the background while running a separate instance of the game (depending on how heavy the game is [heavy or light are terms used to describe how hardware intensive an application is]) could severally bring down performance. Again depending on how hard your game is to run. Mainly how much RAM and CPU it uses. For what you describe, a dedicated server would most likely be over kill. (Also depending on where your friends are. If you are in the same house, you can simply run off of LAN. However if they are across the world you may want to look into running a dedicated server on another computer if you have one just to improve performance a little.)

One way of setting up a simple multiplayer listen server would be to make a main menu UI and add a Host button (you can call it whatever you want). Once you’ve made the UI you could do a OnClicked command. From the OnClicked you could run it into a console command where you tell it to open a map and run it as a listen server.

Also set up a Join button that will allow the player to join your listen server once you’ve hosted it. You could add a
text box or something that tells your friends what your IP is. (127.0.0.1 is the default IP for LAN) If you do not know what your IP address is, you can use a website like ipchicken.com .

Add this to the OnClicked for the Join button:

Add this to the level blueprint. You’ll have to do this to all your maps:

If you want an actual tutorial on that let me know and I can make one.

After you’ve done that, click the little drop down button next to the Play and change the players to 2. Click play and it should open an extra window. If you look around you should see a second player there. You can also press what ever key you set in your input for your main menu (in this example I used P). It’ll open that UI. You can press Host, and it will load a new level as a listen server. Or you could press Join as the other player and it will join a new server. Note: This was set up for running LAN, if you want multiplayer across different networks that is a little more complicated.
how does a server work ?.. I think most of the actions should be processed by the server and not the player (to prevent cheating for example) but… how ?

You are correct in saying that most actions should be taken care of by the server. That is where Run on Server and Switch Has Authority come into play. You can use those functions to give authority to the server only. Also one piece of information you would need to know is that the Game Mode is server only. Meaning anything you put into the game mode will be accessible to the server only. I think [This][5] document will help you a lot.

As far as using blueprints only, yes you can! It may be a little harder and you will have some limitations, for example it probably won’t run massive Battlefield like maps with 64 players on it. (I don’t know, as I’ve never done a multiplayer game with blueprints with more than 8 players.) If you can, I would recommend learning C++ as it is faster and easier to setup once you’ve learned it. However, that is not for everyone. But from the sounds of the type of game you want to make, you shouldn’t have any problem.

You may also want to check [This][6] out on the marketplace. It has multiplayer already setup and two different game modes already handled. I used it to learn how Networking works with blueprints back when I only used C++. You may also enjoy watching [These][7] tutorials. They may help you a lot.

Making a game, especially an FPS is a very hard task with a lot of things that go into it. I wish you the best of luck with your project, if you have any other questions or would like help with your project let me know! Happy coding!

What would you recommend for a real fire arm ? I’d guess it’s the line trace and I actually had this idea before starting but does that allow you to draw things ? I mean if you play CS:GO for example you do see things related to bullets, even if they hit you instantly when they’re fired.

Thank you for the server thing, I saw a tutorial on YouTube that showed how to create a basic multiplayer game, I’ll look further into it assap.

Finally, as far as I know, I won’t need any “new” thing, will I ? I mean, everything seems to be handled by UE4 (for example for moving, jumping…), am I wrong ?

Thanks

Thank you for your answer. I saw a video explaining exactly this, and I thought it was great (seems like a lot of the networking is handled by UE4).
Concerning C++, I don’t really have the time for this now, but I probably will one day (I have strong bases in other languages but C++ for UE seems really… difficult).
Thank you !

What do you mean by the “new” thing? Are you referring to animations? Cause if you are, you’ll have to buy or make them. There a few basic ones on the marketplace you can download. As far as the programming movement, you will have to do that. Unreal is just the platform for development. It does not actually do it for you. Tesla Dev and Virtus Learning Hub have some great tutorials.

No, I was talking about new things for networking.

Concerning animations, I had a few questions too. Until now, I’ve been using Mixamo which is quite great when you have the drawing skills of a… Goat. Though, concerning for example reloading animation, how do I handle this ? I saw UE4 had a “Record animation” feature, is it suitable or totally useless ? When two actors are involved (eg a character reloading a gun and the gun itself) what should I use to make it… Clean ? Do I have to create an animation for the character like if he was taking the magazine and an animation for the gun as its magazine was taken away and then use an animation montage to combine both or am I getting it wrong ?

For the “new things”, the only one missing for my project was the possibility to kick players from my dedicated servers

About real fire arm, I don’t really know, but in PayDay 2 we can saw their bullets, but they are slow (imo) for fire arms …

Don’t worry for C++, it’s like php but with & and * sometimes ><

You got most of the answers. Since I had nothing to answer for yet I can help you when you have a specific question. Just drop me a PM.

Also when you ask yourself like “What should be the BEST USAGE CASE” then I recommend you to take a look into ShooterGameExample. If it’s something much more complicated: download UnrealTournament source code but you will need to write it down since there are a lot of networking safe / anti-cheating function steps.

I would recommend you to take a look into this guy’s networking / physics / networking physics articles:

And unless there is no big reason; don’t give up :wink:

Cheers,

I’ll try to see bullets in Payday 2 since I have it… But do you think it means they use projectiles ? I mean, I take the CS:GO example once more because I’ve played it a lot. In CS:GO, you don’t really see the bullets (I believe) but you do see some things on their way, like little yellow light ? Or that could be the bullets too, though I find it weird since bullets hit instantly in the game…

Thanks for proposing me, I probably will since I encounter a lot of problems with things I thought were simple (mostly related to animations).

I’ll give a shot to the example, I’m downloading it right now.

And thanks for the link, I’ll try to read what I can find.

EDIT : how do I send you a PM ?

The yellow light you are talking about are called tracers. Yes, you can do that in Unreal Engine. It is not to difficult. However, you will have to make the projectile or buy them. The bullet hole you see when it hits the wall are decals, there are some great decals and projectiles on the marketplace if you don’t want to make your own. (Which is a very time consuming task) For the type of game you described, I would not really worry about that for now. What you should do when starting out making a game is to write down everything. From how the movement will work (ex. in the game my company is making, we all got together and brainstormed and wrote down ideas. Like, how we wanted wall running and parkour to be a big focus) When you write all your ideas down, you can hone down what the basics of your game are. Don’t worry about those small details things, like projectiles and decals. You need to build a working game first.

Again using my game for example, I started with the backend programming and got it done first before even thinking about all the cool things I wanted to add. Because of this, I had a working game and playable in multiplayer in the first week. After that it was just play testing and adding the cool things I wanted to add. You have to make some sort of timeline for you to follow. That way you don’t get over your head. In your case, since you are still learning. Make a list of all the things you need to learn. For example, your list could be like: Day 1, make a first person camera with head bob. Day 2, make a aim offset, Day 3, make a working gun. It will also give you a rough idea on how long your project will take.

Thanks for the info about the tracers. But I don’t understand why I need projectiles if I don’t use a projectile actor with ProjectileComponent…

Well actually I wrote a few things before beginning anything, but even the basics seem to cause problems… Like what I was thinking about was just creating a project where I can have a weapon held by the player and that can be fired and reloaded. I followed a few tutorials (actually I already had for animations of the character) but nothing worked, and I can’t find answer to some of my questions, and most of them are about the animations for now (I’ve tried to help people on other projects and animations were always where it had problems). I don’t know how to animate a shot and I can’t find anything to explain me. I didn’t find anything neither about how I can “sync” two animations (character shooting + weapon shooting) in one to use them in the game. Finally, I don’t even know how I can record animations or even if I need animations for the gun or if it can be done directly in UE4. If you have anywhere I can learn about this, I’d be delighted.

I think I understand what it is you are asking now. I thought you were referring to projectile as a tracer, getting the two mixed up. That was my mistake. You do not need to create a projectile, it is really only needed if you are trying to make high detail games or are making weapons with slow travel speeds. But if you are just making a rifle with a high muzzle velocity, you can easily get away with just a impact decal and a muzzle flash. As far as “blending” the animations, you would do that in what is called a blendspace. You create one by right clicking in the content browser. It should be under animations if I remember correctly. You don’t have to blend a animation with the gun and character. You would just set up an animation for when you fire the gun to simulate the recoil. Attaching a gun to a character is actually not as easy as you might think. When guiding people on making shooter games, I also suggest that they finish all of their movement before they try to work on the weapons. As it can be very frustrating. At least in my experience, making the guns first always caused me more stress.

As far as recording animations, you can not do that in Unreal Engine. The record button you see is not for that. If you want to animate you’ll have to do that in a program like Maya or 3DS Max. (You can download 3 year non-commercial student versions of those or use blender which is 100% free). The art of animating is something that takes a lot of time and practice. It is not something you can master in a full hours.

You can setup a project with a fire able weapon with reloading animations without projectiles. Unless it is a laser gun or a bow and arrow were you would need to see the projectile you don’t really have to create on. As long as you set up the code right, you can still have an actor take damage without them actually being hit with something.

There is a little more to it than that lol

Thank you for this answer clearing things up. Though I still have questions, concerning the animations. Why would I use a blendspace ? I saw it was used to combine two animations (when you have an animation for going forward and one for strafing for example), why would I need one here ?

Another thing is for reloading the gun. When I reload, I have to take the magazine out and then to put it back (considering I don’t spawn a new one, I just keep the same but it will be out of the screen so the player won’t know it’s the same hehe), but that means I have to have a magazine and a weapon “body” that are not “stuck”, right ? - by stuck I mean that they’re not part of the same model. Also, I need an animation of firing and reloading for each gun I have in the game, don’t I ?

Finally, how do I attach a weapon ? I’d use sockets and create sockets for each gun (so it’s adapted) but I don’t know if there is a better way to do it.

I think what you are looking for is here: http://shootertutorial.com/tutorials/

I would suggest following all of those tutorials, that will probably answer most of your questions. As far as the animating guns goes. When you model the weapon, you’ll model the mag as a different mesh from the main weapon.

I of course know this website, the thing is that the guy uses a lot of assets from the marketplace, assets that I don’t have the means to pay.

You don’t need those assets to follow his tutorials. You can just use the default UE4 mannequin in place of the character or make your own. Unless you already have a gun model created, or have the money to buy one you won’t really be able to test the sockets and what not. You need the assets before you can start scripting for them.