Jump to content
  • Advertisement
  • entry
    1
  • comments
    0
  • views
    361

Unreal Engine - Pong

Sign in to follow this  
JToiviainen

953 views

It's been a quite long time since I previously used Unreal Engine to build games. If I remember correctly, the previous game was some kind of first person horror adventure game where the player was exploring the darkness in some kind of mansion or such. This mansion contained faceless doll creatures that would attack the player when certain conditions were met. Game had no weapons and player was only equipped with a small flashlight that allowed him/her to explore the mysterious rooms of the mansion. This project was a school project we created with my three classmates when I was studying my bachelor's degree in Turku University of Applied Sciences. So it's been around seven years since I previously touched Unreal Engine. And now, I decided that it's a time to dive back into the world of Unreal Engine and create something super cool... like an another Pong clone!

Installation of Unreal Engine

The installation process for Unreal Engine is quite interesting. Before the installation package could be downloaded, I needed to create an Epic Account. This account was then used to download the Epic Game Launcher application which was then used to install the actual Unreal Engine. I'm not sure why the installation needs to have so many steps, but perhaps Epic has good reasons behind it.

Installation was now complete, and it was a time to start the engine. During the startup it started to compile shaders, which took a while. I also had some problems with the Visual Studio linkage as the engine throw some errors about how it failed to compile sources for the project. After some googling I found out that I needed to install "Game development with C++"-module to my Visual Studio to get this link to work correctly. After installing the module, I was able to start a new project without errors and now I was ready to start my journey with the engine.

Scenes

As with my previous implementations, I decided to use three different scenes. One scene for the main menu, one for the in-game court and one for the results screen shown after the match has ended. This kind of scene set requires only the following three transitions.

  • main-menu --> court, after the player has selected the "Start Game" menu option.
  • court --> end-game, after either player has reached the score limit.
  • end-game --> main-menu, after the enter key has been pressed.

In addition, we also have a special transition, which starts from the main-menu and exists the application after the user selects the "Exit" menu option.

If I haven't understood completely wrong, it seems that Unreal Engine calls scenes as levels. This makes my scene split quite interesting, as now I have a main-menu level and end-game level in my implementation. Somehow I feel that I've done something in a bit odd or wrong way.... But it works!

Main-Menu

I decided to follow the same main menu structure what I used with my other Pong implementations. This view contains only four different components that should be shown on a top of each other. One label for the game title, another for the menu usage instructions and two buttons which are used to start or exit the game. This kind of simple structure would provide a nice way to get known with the basics of the user interface system in Unreal Engine.

Unreal Engine seems to have a support for basic and even complex user interface constructions via the Unreal Motion Graphics (UMG). After watching a couple videos, some tutorials and documentation, I managed to implement a simple user interface for the main menu. See the following images.

main-menu.thumb.png.9ba7028c6a2f92b2570c847ddf3a0e5e.png

main-menu-blueprints.png.928a5c751cadc03e588ebdcc17c55aa1.png

Thanks to blueprints, this was super easy to do. I only needed to add couple click-listeners and wire them with some simple navigation commands to get the transitions to work. Blueprints are actually reminding me of the old Kismet(?) system that was available in some version of the engine. I have to admit that I usually prefer doing all logic by coding it line-by-line. Still, creating the graphical user interface logic with a graphical tool felt natural. Perhaps it's a psychological thing or such.

To get the main-menu "level" working, I also needed to modify the level blueprints so the level would create and attach the main menu widget to viewport when the game starts. See the following image of the blueprints that were used as the level blueprints when the main menu was created.

main-menu-level-blueprints.thumb.png.594b24a5160a6283f43daae430c2d996.png

This blueprint contains the same kind of logic that is actually used in quite many tutorials. And it works! At least for this kind of small game.

Court

Now it was a time to move on to implement the court scene. For this scene, it was quite clear for me to follow the same kind of structure that I used with my previous Pong implementations. This structure contains two movable paddles, one moving ball, two collideable walls, two invisible goal areas, two non-collideable score markers and a one non-collideable vertical center-line at the center of the screen. This structure can be seen from the following image.

pong.png.c8a4a46a0320f652b38cf9b4585da919.png

The previous image contains flags on each entity to mark the behavioral role of the entity. C is for collideable entities, which may interact with other entities. V is for visible entities that are rendered i.e. can be seen by the users. M is for moving entities that can move around the scene and P is for entities that are acting as player avatars i.e. can be controlled by the players. This kind of notation helps (at least me) to implement all items for the scene.

With my previous Pong implementations (i.e. JavaFX, JavaScript, SDL2 and Unity) I used geometry generation support to create graphics for the entities. This time, I decided to use the Unreal Engine's Paper2D sprite support to create visuals for the entities. I managed to use GIMP to write the following kind of sprite sheet for the court scene.

pong_sprites.png.56d56d7adcaca085d93ac7f5b8212162.png

Well... I'm quite sure that my sheet does not follow the "industry" standards how sheets should be created but it works! There's some redundancy on some elements and such, but I wanted to e.g. keep paddle and number one as a separate element in the sheet and also to keep the ball separated from the middle line sprite section. The sheet used in the game differs from the image shown here as it has a transparent background. I also decided to use TGA as I heard and read about some transparency problems with the PNG, which made this as the first time I used TGA in any of my games.

Now it was a time to start creating some logic for the game entities. I first started with the C++ API but found that there were too many C++ monsters along this road. One of the monsters was that there were strange communication problems between the Unreal Engine and Visual Studio which made my source files to be opened multiple times. I even faced a a monster which did completely collapse my project so I couldn't event re-open it before I manually deleted some of my "invalid" code structures from the project. I'm quite sure that the C++ API is great when studied thoughtfully but I decided to take a shortcut and leave the huge C++ API aside and take the Blueprints path.

I had a bit confusion about where to store the actual game logic as there seems to be multiple suitable layers. I also found out that there is no actually a "right place" to put it as people seemed to put it in different places depending on the size and the features of the game. I decided to scatter my game logic into multiple places, where the level blueprint was acting as a centralized router for global events. I think that this worked quite well as the level blueprint has a good ability to directly refer to all actors available in the current level. After I did some study about how the event passing mechanism works, the communication between the game entities was quite easy to implement. 

I also had a requirement where the game results needed to be passed to end-game scene where they could be shown to players. I first thought that it would be quite trivial to implement this in a elegant way. However, I found out that my game results were attached to a wrong place as I needed a storage which would persist across the scene changes. I googled a bit and found out a solution to use a custom Game Instance to store this kind of data.

And then I finally managed to get all logical pieces gathered into a working solution.... 

ingame.png.8093568813ed01f0bca5463ea874510d.png

Afterthoughts

I must admit that Unreal Engine is huge! It has lots of cool features and a support for many platforms and things that I haven't ever heard of. Those things that I learned about the Unreal Engine C++ API and Blueprints were only a tiny scratch of the whole set of functionality that awaits within. It's not a surprise that Unreal Engine is a globally popular game engine in game studios. I also think I managed to get a quite well working implementation for my game and perhaps I'm going to dig deeper (and even try the C++ API once more) with some later project.

Thanks for reading!

Game source in GitHub: https://github.com/toivjon/ue4-pong

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By sausagejohnson
      All games written with Orx have a profile screen that can be called up to monitor for any inefficiencies or bottlenecks.
      Iarwain will be demonstrating the Profile Mode for Orx over twitch tomorrow night at:
      Come along if you're interested to learn about it. There will be an opportunity to cover any topics after the demo.
      Here's some time zones as a guide to when it's on:
      Montréal, Canada      Tue, 11 Dec 2018 at 1:00 am EST     
      Rome, Italy           Tue, 11 Dec 2018 at 7:00 am CET     
      San Francisco, USA    Mon, 10 Dec 2018 at 10:00 pm PST    
      Sydney, Australia     Tue, 11 Dec 2018 at 5:00 pm AEDT    
      You can check other time zones here: https://www.timeanddate.com/worldclock/converter.html?iso=20181211T060000&p1=165&p2=215&p3=224&p4=240
       
       

    • By GameDev.net
      GameDaily.Biz spoke to Improbable about its new shortcuts to multiplayer game development for Unity and Unreal. 

      Improbable helps game developers build believable online worlds with its bespoke technology, SpatialOS. Now, that task is much easier and accessible for those building games on the technology with the recent release of the SpatialOS Game Development Kit (GDK) for Unity. With these kits, Improbable hopes that developers find it easier to create vast, dynamic and unique worlds.
      This GDK for Unity includes a 200-gamer, first-person project that allows developers to experiment and tinker with their ideas for what their vision of a multiplayer game will look like.
      GameDaily.Biz met with Improbable’s Head of Product Marketing, Paul Thomas, and Head of Comms, Daniel Nye Griffiths, to speak about the SpatialOS GDK for Unity, as well as the upcoming launch of the SpatialOS GDK for Unreal Engine.
      In its first week, the SpatialOS GDK for Unity achieved over 2,000 developer sign ups to use it. “What we're trying to do is basically make it really fast for people to build multiplayer games,” said Thomas. “It comes with all the multiplayer networking so that developers don’t have to do any multiplayer networking. It comes with feature modules to allow [easy] solutions to common multiplayer problems, like player movement and shooting. And it comes with a cool starter project where you have 200 players in a free-for-all scenario. You can obviously use the power of SpatialOS to scale that project up to more players, with NPCs, and things like that. It gives people a really good base to start building multiplayer games.”
      There are several games currently in development or early access that utilize SpatialOS. The first into Early Access was Spilt Milk Studios’ Lazarus, a space MMO where the player becomes a pilot in a universe that ends every week, complete with a map that’s twice the size of Austria. Additionally, Bossa Studios released its survival exploration game Worlds Adrift into Steam Early Access earlier this year.
      Also using SpatialOS is Scavengers from Midwinter Entertainment, a studio founded by former 343 Industries studio head and Halo 4 Creative Director, Josh Holmes; the game is heavily inspired by his Halo 5: Guardians’ multiplayer mode, Warzone. Right alongside that company, Berlin-based Klang Studios is working on Seed, a simulation MMO that, according to its developers, lets players “interact and collaborate to create a world driven by real emotion and aspiration.”
      According to Thomas, for those looking to use the SpatialOS GDK for Unity, there is no limit to  what their games can do with Improbable’s tech.
      “What we're doing is expanding the possible gameplay you can do. Traditionally, when you make a multiplayer game, you're constrained by one single server. So you can say you have a 64-player game with a handful of NPCs or you could have a world that's 3km by 3km. With Spatial, you can go beyond that, test a much broader canvas to start thinking about different gameplay.”
      “You can go for a massive online persistent MMO with 10,000 players and hundreds of thousands of NPCs, something very, very vast and big like that. But you can also have smaller experiences. For example, there's a lot of interesting space in just extending what you see in the Battle Royale genre and session-based gameplay.”
      Thomas continued: “Our partners at Automaton have a game in development called Mavericks. The interesting thing there is they have a Battle Royale with 1,000 people, but what I really find interesting is the gameplay mechanics they've put in, like footprints so you can track people. They've added a cool fire propagation mechanic so you can start a fire that  spreads across the map and changes the world. Or you can add destructible buildings and things like that.”
      “So I think even looking at smaller scale games, we add a lot of value in terms of the new gameplay you can start adding. I'm just interested to see what people do with this extra power - what they can come up with.”
      While Battle Royale games and MMOs are obvious standouts for genres that best fit with SpatialOS, Thomas introduced some other ideas of genres that could benefit from the technology.
      “I also think there's a space for very interesting MMORTSs as well,” he said. “An RTS where you have persistent systems, like telling AIs to do things and then coming back to them a week later and seeing what's happened is an interesting space.”
      “I also see interesting mobile experiences that could come up. Having these worlds where you lay down some interesting things and then come back a few weeks later to see how they've evolved and changed, and the massive player interaction. Say for example with Pokemon Go, we can actually roam around the world and battle on the streets. I can see something like that working very well. Again, these are just ideas we've had and talked to people about. It's about giving people that flexibility and the ability to explore these ideas.”
      Klang’s Seed
      Griffiths added the possibility of events in a game that will have a massive, rippling, and lasting impact on its world as something that has people excited. One example he gives is how someone on one side of the map can do something that’ll have a knock-on effect for the rest of the world in real time.
      “There's a whole bunch of different angles you can take, some of which are about much larger player numbers or a much larger map, but there are other things you can do which are taking a relatively constrained game experience, a smaller map, a smaller number of players and adding richness to the game as well.”
      In fact, this is something that Thomas refers to as a “persistent in memory database,” meaning that for every object in the game world, there’s a history. Two examples cited by Thomas: “...a player could chop down a tree and that tree stays disappeared forever. Or a player can kill a big monster that was raiding a town and that town no longer gets raided by that monster, and this changes the dynamics of the world. Worlds can have a history. That means players can have a lot more meaning in these MMO worlds.”
      “Normally in MMOs, they're kinda like roller coaster rides: you go into a dungeon, you kill the boss and that guy respawns. It all resets,” Thomas continues. “But in Spatial MMOs, you could have these persistent effects that should change the gameplay meaningfully for all the rest of the player base.”
      “The other one I think that is interesting is the level of dynamism that you could have. So because you can have so much more server-side compute, you could potentially have NPCs roaming around the world changing their mind and deciding all of a sudden, 'oh, we're going to attack this player's base' or 'we're gonna go attack this town' and they have a lot more range and emotion and intelligence to them that you'd not see in other MMOs.
      “Normally in MMOs, NPCs sit there tethered. You go near them and they come and attack you, you run away, and they go back to where they were. In a Spatial MMO, that NPC can trace you across the whole map or a group of them can decide to get together and attack someone..”

      Bossa Studios' Worlds Adrift
       

      Next week, Improbable plans to launch its SpatialOS GDK for Unreal Engine, which will have a big focus on ease of use for access to Unreal, as well as a big emphasis on porting your projects to SpatialOS.
      “One of the things we'll be trying to push is a porting guide so you'll be able to take your existing Unreal game, move it onto SpatialOS and then you can grow to expand it with new and extra gameplay,” says Thomas. “ You can bring across your existing Unreal game and it feels very, very native and similar to Unreal if you're familiar with Unreal.”
      Griffiths continued, explaining how testing these experiences includes free cloud deployments, to a certain point. “If you're developing in SpatialOS in other ways, we provide a sandbox environment so you can get your game running. When you’re happy, you can port it over and sort of experiment with it in a free sandbox environment with a small number of cores to get started.”
      Based on what we learned, Improbable’s SpatialOS GDK for Unity will give developers enhanced flexibility to produce more in depth and engaging videos games. That said, we look forward to catching up with the company in the near future to see how this exciting technology is being used in the different games that we play.
    • By Batcloud
      Hello, my name is Giovanni Bruno and I developed a game in a week that creates a casual experience of reflex and focus on the iOS platform. I'd love to hear your take on the game. Would you have 20 seconds to watch a little gameplay?   Gameplay link: https://www.youtube.com/watch?v=A7aGA9yVpEQ Download link: https://itunes.apple.com/us/app/levita/id1445334524?ls=1&mt=8   More about me: I've been an iOS developer since 2017 when I joined Apple Developer Academy Mackenzie in Brazil, I had a great opportunity to be a WWDC 2018 scholarship winner and attend the event. Now I'm venturing into the development of casual games for iOS, I hope to create ever better experiences that enchant people from all over the world. I know that the game is very simple, but I hope that someone play it!
    • By Ozee62
      Hi,
      At the moment I want to create a team to make a new top down shooter game for Windows and Mobile. 
      Our store page https://play.google.com/store/apps/dev?id=8448896228303860944
      I need gamemaker programmers and 2D artists, You can send your cv / works on; 
      contact@massoftgames.com
      And you can add me on Discord;
      RuLing62
      Thank you, and see you later!
       
    • By mrDIMAS
      Hello!
      For more that two years I'm making my 2D sandbox adventure RPG with generated and almost fully destructible world. Recently the project become open-source and detailed description can be found here - https://github.com/mrDIMAS/TheDwarfAdventure
      Here is gameplay video (very short) with core mechanics:
      Latest stable build can be found here - https://github.com/mrDIMAS/TheDwarfAdventure/releases
      I need some feedback and if you found a bug - create an issue - this will help me a lot.
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!