vendredi 22 janvier 2016

ue4 multiple level zoning, and architecture

It is important to understand how ue4 works to make a multiplayer game.
A dedicated server runs only one level (physics, replication, ...).
You have multiple possibilities. If all your players are changing of zone at same time, and the zone is loaded only at this moment, your server can change zone, and load it, and the clients will do the same.
One server is enough

But if you wish to have several zone running at same time, you must keep in mind, that you must have one dedicated server per zone.
The client will connect to the server it needs at the moment it wants.
From my side, when client is launched, it is not connected. It shows a level with a tiny scene, and an UI to fill knickname, and a button to connect.
Once player clicks on connect, I send a connection to the first server using IP and port.
it is enough. Once connected, the server will send the level to load, and replicate actors which need to be replicated.

during game, maybe player wish to change zone, to travel elsewhere. I will disconnect to current server, probably load a temporary level, with tiny scene, to wait connection to other server, and then I will connect to a new IP/Port, to reach the new server hosting the level I want to travel to.
Once again, the server will send the name of level to load, and replicate what it needs.

Finally it is quite standard as an architecture, but you don't have choice, it is way to do.

I got a question on instantied zone. I think best way is to have a running server by instance too.

UE4 packaging

The first times I packaged my game, I was totally afraid by the time it took. on my laptop, it was between 1 and 2 hour, with very lot of steps.

Looking at log, I saw that lot of components was taken in the package, html5, VR, ... and so on, what the hell, I have no needing of all of this.

For information, all this components are standard plugin in ue4 editor. So just go to plugins menu, and disabled all you don't need. your package will be better, and you will package quicker :D


vendredi 8 janvier 2016

Networking : day 3 : torque

After moving forward, next step is to rotate on 2 axis (I choosed 2 for more convenient, I don't like roll :p).

As seen before, the keyboard input are given on client side, and the physics is managed on server side.
So the input must be treated on remote, and the modification value done on server.

First, create input in project settings : using QD and ZS.













Next, we will in pawn blueprint, create an addTorque server event (custom event), running on server, with a vector in input.



 Now we can react at leftright event, and calculate the vector to apply torque



Notice the switch has autority... It is keyboard input, so we have to use remote activity.
 And now, we have to apply torque server side



I think switch has authority is not necessary here, it is more convenient to show example...

Finally, we will catch updown event, to pitch the spaceship


 Done...

For now, you can speed up to go forward, apply torque to turn right/left, or up/down.

Because you are using physics, reaction on bouncing, will be quite realistics

mercredi 6 janvier 2016

networking ue4 : day 2

You got speed management... but now how to move your pawn?

First of all, check that your spaceship is using physics... Go to your pawn blueprint, and look at your static mesh


Check simulate physics, put linear and angular damping at 1, to have enough frictions, to slow your ship in rotation or movement (otherwise it will speed very highly, and rotate very quickly... :p)

It is a space game, I disabled gravity.

Physics is important  on server, but totally unusefull on client, so desactivate it, on begin play event.



As you see you choose remote on switch autority, to disable physics simulation only on client side.

I am using physics because, I wish to have bounce behavior, collision, and so on. So I will add Force to my mesh, to make it move forward.
I will do this on server



And this is it, your pawn is moving. But client didn't see the move...
I created a custom event, I will use to broadcast the new position/rotation to client. I give to it, vector and rotator as parameter.
Multicast == broadcasting


On server side, I will get my rotation, and location, and give it to my custom event. Custom event will run on client side, I set to my mesh, the new position and location.


Global schema is this
































ue4 : networking day1

The aim of my game is to do a multiplayer game, with a dedicated server and clients.

It was sometimes hard to find my way, to understand networking in unreal engine, so I will try to take time to explain different things about networking, and to illustrate what I 've done in my game about the different topic.

If you need, more precise focus, let me know.

First of all, because it is dedicated server, server has control over all things. You have to draw blueprint in same blueprint for case of "server", and case of "client".

It is important to understand this. It is important also to understand what will be managed by server and replicated to client, and what is manage by client.

On client board, you will manage essentially UI, special effects, keyboard/mouse input management...
Server will manage AI, movement, physics, spawning, ...

So every time, you wish to move your pawn, through keyboard input, you will have to send the information to server, which will move the pawn, and replicate/broadcast new position.

Ok with this very few basics...

First, I will show you how to manage increase/decrease speed on my spaceship.
First I create new input in project settings








 Next in my pawn Blueprint, I create two variables, speed, and speedmax.
Speed will be replicated. It is an information needed by client to manage UI and FX for example.
Replication is always from server to client.



I ve created next a new custom event in my blueprint. The event receives the new speed, and set the variable with it.
Event must be run on server



 Finally, I receive my speed input (through A or W keyboard input), and I manage the increase of speed, and send it to server.





Pay Attention on switch authority. Switch authority allows to run what is after on server, or client. Here, because it is a client input, I have to manage following on client. So I choose remote.
If it was an event about collision for example, I must switch on authority, to manage it only on server.

If you don't use this switch, it will be run on both (client and server), and you can have strange behavior or maybe error. For example, if you manage to update an UI, on dedicated server, you will have errors, because there is no window for server.

Here, you will manage keyboard input to increase speed, and send the update to server.
Server will update speed variable, and because of that, the update will be replicated to all client.

To do better, you can send the input to server, which will manage the different test case, to be sure and guarantee no cheat :D


























mardi 5 janvier 2016

ue4 scalablity : graphics settings

It is quite easy to change graphical settings if you are launching your game in PIE, through menu configurations.

But for dedicated server + game, you have to used command line, using ue4editor yourproject yourmap -game or -server.

It is possible to change graphical settings in blueprint, launching command console as this :


















You can use ini files to manage this, and save user settings.



















 Be sure to create a paragraph  Scalabilitygroups
[/Script/Engine.GameUserSettings]
bUseVSync=False
ResolutionSizeX=1600
ResolutionSizeY=900
LastUserConfirmedResolutionSizeX=1600
LastUserConfirmedResolutionSizeY=900
WindowPosX=-1
WindowPosY=-1
bUseDesktopResolutionForFullscreen=False
FullscreenMode=2
LastConfirmedFullscreenMode=2
Version=5
AudioQualityLevel=0

[ScalabilityGroups]
sg.ResolutionQuality=25
sg.ViewDistanceQuality=1
sg.AntiAliasingquality=1
sg.ShadowQuality=1
sg.postprocessquality=1
sg.TextureQuality=1
sg.EffectsQuality=1


And the 6 parameters at bottom are from 0 to 3 (3 is epic graphisms, 0 lowest level).
resolutionquality can be put from 0 to 100.








lundi 4 janvier 2016

Targeting Hud :reticle, floating name

Something important is to have a targeting system, and have a reticle around ennemies.

It is quite easy in ue4, because you have a function to transform 3D position to screen position.

First step, import your reticle, or crosshair as a texture into your content browser.

I suppose you've created your own HUD blueprint, and load it as default to your map.

Open your HUD blueprint.

You will react at receive draw HUD event.

I've created a pawn BP, for my ennemies, with a static mesh inside. Nothing more is needed for this paper.

First step,  I will loop through all actors with the class myEnnemyPawnBP and for the remaining, I think a picture is enough to understand.
I put the reticle around the ennemy (so the minus 35 because my reticle make 70*70 pixels), and I put its name above the reticle in red.






Emissive material through blueprint

Hello,

Something fun is to use emissive material. I got a static mesh, with a material containing texture, bumping, and emissive texture.

It is allowing you to make shine some parts of your mesh, without managing lights (as an external object).

My purpose was to make shining the engine when speed up.

First step is to modify your material, to add a parameter (scalar parameter) and multiply it to the emissive texture.






Next, go out of the texture, go back to content browser, right click on your material, to create a material instance.

In previous step, I've created a pawn blueprint, with speed and speedmax variable, and with a static mesh component referencing my mesh.

Open this blueprint, at the begin play event, create a dynamic material for your static mesh.
Fill the source material, with the name of your instantiated material, you created step before.




Every tick, I check the speed, to make glowing engine or not.

I calculate a prcent speed, to make shine depending of the engine's power, I retrieve material from my mesh (here my mesh has only one material, so it is easy, I retrieve materials at index 0)
I cast to material instance dynamic, and I use set scalar parameter value, where I precise the parameter created in first step into my material.




Now in game, if you increase the speed, engine will shime more and more...
Hello,

New beginning for shimstar... again
All these years, I grew up my skills around 3D, networking, game design... and I made something very cool around shimstar on panda3d. I think I have something quite mature, and I am proud of this, because I wrote lot of code to be at this step.

But I choosed to do a restart using a game engine mature, known of the market. It is long time I looked at Unreal Engine, and because of this, I choosed to use it for this next step.
Unity was another choice possible... but for different reasons, not all very consistent, I choosed unreal engine 4.

On this first step, I think I will try to create something simpler than a mmorpg :D
I will keep the multiplayer stuff, and implement some missions to do with AI. Once in space, you will have things to do, linked between them. For example, once you kill the first enemies, you will have to reach a point to protect something, ... and so on.

My feelings after 3 months, is that unreal engine is not for totally beginners. I think if you have a good background on 3D, graphisms, gameplay, it will enhance your ability to build a good game, otherwise you will spend lot of time to do something, that anoter engine can do easier.

I will use this blog, to show some stuff  I do with unreal engine. Lot of things can be done without coding, using a workflow tools named blueprint.

I hope it can be usefull for other people.