Download

Announcing Section #4 for Survival Game - Setting up the survival game-loop

We’re announcing the fourth section of the survival sample game today! The documentation will be up by the end of next week, in the meanwhile you can grab the latest source at GitHub (https://github.com/tomlooman/EpicSurvivalGameSeries). Which will continuously be worked on for the 12 week period! Use the tagged release for stable builds each section, once available.

UPDATE: Wiki Docs are now available for this section!

LINK TO MAIN THREAD

In this section we will setup the game loop with scoring, failure state and a day night cycle that will affect the spawning of enemies and items.

Some of the concepts that will be covered include:

  • Controlling a dynamic time of day through the gamemode.
  • Spawning enemy AI and items (food, weapons) during gameplay.
  • Showing (replicated) game information through the HUD (time of day, score, kills etc.)
  • Replicating score and the gamestate on clients (kills, time of day etc.)

Every two weeks a new section will be announced with a new thread alongside it! Please use this thread for questions and feedback you might have on the section!

UPDATE: Wiki Docs are now available for this section!

Screenshots:

survival_section4_banner01.jpg

c2e9d70c88c40fcbedd7992aa05cc37ad571470c.jpeg

Still have to explore Section 3 :smiley:

I’m really interested about game-loop and how to manage it with UE4, cool section Tom, thank!

A quick update on what I’m working on right now:

Smooth networked time of day. The day/night cycle will influence scoring and enemy (maybe even behavior of those enemies)

section4_timeofday01.jpg

(Should really be viewed in motion, video coming soon!

Hey Tom,

Ty so much for these awesome tutorials. I been stuck on replicating character rotation when using SetActorRotation, It rotates fine on the server side, but the client side doesnt always change the rotation.

EDIT: I had to go back and relook at your gits, videos,etc. I just had to Replicate the spellbar with CondOwneronly.

Ty again!

Hey Tom,

Great Idea doing such a widespread comprehensive tutorial series for this, given that OpenWorld was just promoted at GDC :wink:

Btw. porting to 4.8 shouldn’t induce too much trouble, mostly some changes to the override specifier and some undeclared identifiers from what i’ve been seeing in the log when trying to convert.

I guess you are waiting for a stable release though?

Im basicly just saying thanks and keep up the good work!

Greetings

Chris

Hi! Thanks! Yeah definitely waiting for 4.8 stable, there are some blocking bugs in the preview that will break multiplayer. The project will be 4.8 compatible for sure though.

Cheers

  • Tom

May I ask will you consider having player vs player kills / deaths counted as well as kills on AI?

That wouldn’t be too difficult to implement. For the current gamemode however it’s 2 player coop vs. environment/AI. I think since a lot of people would like to use this “template” for open world purposes instead I will consider setting up and splitting up some code to make all that easier (eg. moving all closed area coop into a separate gamemode class, so it can be left out while maintaining the base framework for gamerules with open worlds etc. All that is TBD though, there is still two sections to go which I’ll plan out soon.

Oh haha great that you found an answer. I was typing one out the other day, but didn’t get to finish it :slight_smile:

A snippet from that anwser that is still of use even though you solved your initial problem:

*"…You probably even want to look into (Actor)Components instead of using Actor for your spells, and attach the spells as components to your character. ActorComponents are more efficient and generally clearer who owns it (and it won’t exist as an object in your world anymore, which is a bit unneccessary) But that is up to you.

Docs on Component Replication: https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Actors/Components/index.html

At that time you’d also want to replicate the spellbar, using a condition COND_OwnerOnly (look at the commented code of GetLifetimeReplicatedProps in SCharacter.cpp for an example) since only the server and owning player care about this array…"*

I skipped the rest of the answer since you resolved it already

Cheers,

Tom

The docs for Section 4 are almost done! I’ve been adding some improvements to the code to simplify and cleanup some of the examples before releasing the docs.

survival_section4_banner01.jpg

UPDATE: Wiki Docs are now available for this section!

Thank you Tom, shared on Reddit as usual.

That doors in that side remember me something mmm, no idea what… xD
Nice work Tom, but for that type of example/game will be nice a bigger map with respawn of the items or something ?

Thanks Tom for this tutorial series.

One question, I’ve noticed some calculation for the day/ nightcycle are done in the gamestate class…could/ should I do this calculations inside the TimeOfDayManager or another Actor class if our game is singleplayer only? From what I’ve read GameState is only useful for multiplayer.

Hi Tom, I took the right to update myself the Main documentation page on the wiki to add section 4 with useful links.

I hope its okay for you!

Cheers!

Great! I forgot to update the page yesterday, thanks!

A GameState will always exist, even for singleplayer games. you wouldn’t need to do any of the replication, but the system doesn’t need to change.

I’ve been thinking about making a large open map, I’d need to dig into that myself before I could do a section on it. This is something that would be very interesting perhaps post-4.8 which introduces a lot of open world improvements.

Ill def check out the components, ty.

Atm I just realized that storing a spell in my spellbar (Tarray uproperty) only remains in the spellbar for 60 seconds (because the spell gets destroyed in the world). Mind you the only way to keep it inside the spellbar is to simply hide the mesh and remove collision, but that means that it presists through the world. How viable is it to go this route? where by the end of a match we have something like a 1000 hidden actors with no collision.

I know it sounds pretty inefficient but what alternatives do I have that would be efficient on a multiplayer game. (I know i can directly spawn from a TArray of Tsubobjects, but for reasons such as spell CD, setting instigator, etc, It actually has to be the object stored in the spellbar).

ty

That doesn’t sound right, you might want to split something up into individual pieces. Ideally your spellbar item is NOT the same actor as your actual spell that is performed or picked up / acquired etc.

Whatever is “owned” by the player would be a attached component, anything that is cast with an actual effect could be either the component showing some effect and you calling functions for damage and effect application on the current target w/o the need to generate a new spell actor…or if it’s an actual projectile / duration effect you probably do need to spawn a new actor into the world that exists for the duration of the spell effect.

It all comes down to the design of your system, but this is just a quick suggestion w/o having a lot of details ^^ Hope it helps you out!

  • Tom

EDIT:

Hey Tom,

Sorry for the wall of text lol, so I finally managed to fix the issue by doing the following:

SpellBar = TArray of Objects (like your weapon array) [Fireball][FrostBolt][etc]
SpellBar_Internal = TArray of Tsubclassof [Fireball - Class][FrostBolt - Class][etc - Class]

Lets say I wanted to cast a fireball, so I went to that index and called the function like I previously was (ex: The fireball object managed my spell cooldown) but when it came time to spawn I simply spawned from the fireball class it self.


spellBar[index]->SpawnSpell(spellBar_Internal[index]);

And because the initial spell that I spawned to store in my SpellBar was off the map and never collided with anything, it never got deleted; and remained as a way to manage my cooldowns.

Much Appreciated,

-Ven

Something between version 2 and 4 of this, causes the zombiebots to spawn off of the player. I am not sure what I am missing, if anyone could offer advice.