Chapter 9. C++ Programming – Gameplay

In this chapter, we'll cover the following recipes:

  • Setting up your development environment
  • Displaying text during runtime
  • Networking 101 – creating collectables with networking
  • Saving or loading games and keyboard input with C++
  • Creating custom blueprint nodes

Introduction

So far, we've been using blueprints in order to generate gameplay. This has been great and has worked well, but one of the main advantages that Unreal has over its competition, such as Unity and Cry Engine, is the fact that you can get access to the full source code of the engine and rework it to fit exactly what you're looking for.

It would be quite easy for me to write an entire book just about programming, and within these few pages, I can't possibly cover everything you need to know to write code. Rather, in this chapter, we are going to cover how to set up your development environment and some of the possibilities of programming in C++ for UE4.

Tip

If you are interested in taking this further and learning how to program C++ using UE4, read Learning C++ by Creating Games with UE4 by Packt Publishing.

When to use C++/Blueprints

One of the things that I often hear people asking is whether to use C++ or Blueprints within their projects, or which one is better. As it currently stands, there's not really a straightforward answer to it. If you aren't a programmer at all or feel that you're more of a designer, then blueprints may be better for you due to the fact that it's more visually oriented. However, if you've been coding for years, you may be frustrated with having to use so many nodes to do some actions that you could write in a line of code. Factors such as the number of teammates and the project itself can also be taken under consideration.

It's often a lot easier to transition into C++ after you've been using blueprints and Unreal for a while as you'll be used to how Unreal names certain things, but we'll get some exposure in this chapter as well. That being said, you'll often switch between the two within the same project, with level-specific stuff being done in blueprint and content that will be reused in C++.

In previous versions of the Unreal Engine, runtime performance was something you also needed to consider, but it's less of a problem now. Don't worry about it unless something done in blueprint in your game is going to happen lots of times or is causing your game to slow down a lot. If this does happen, check out the guide on improving performance at https://www.unrealengine.com/blog/how-to-improve-game-thread-cpu-performance.

Often in game studios, designers will prototype a game mechanic so that it feels right and if it's decided to be used in the game, it's revisited and if it needs to be revised, a programmer can then reimplement it knowing exactly what the designer had in mind while making it as efficient as possible. Lionhead Studios is currently doing this during the development of their new game Fable Legends. For more information on that, refer to https://www.unrealengine.com/showcase/fable-legends.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.76.213