Book description
Get the best out of your games by scripting them using UE4
About This Book
- A straightforward and easy-to-follow format
- A selection of the most important tasks and problems
- Carefully organized instructions to solve problems efficiently
- Clear explanations of what you did
- Solutions that can be applied to solve real-world problems
Who This Book Is For
This book is intended for game developers who understand the fundamentals of game design and C++ and would like to incorporate native code into the games they make with Unreal. They will be programmers who want to extend the engine, or implement systems and Actors that allow designers control and flexibility when building levels.
What You Will Learn
- Build function libraries (Blueprints) containing reusable code to reduce upkeep
- Move low-level functions from Blueprint into C++ to improve performance
- Abstract away complex implementation details to simplify designer workflows
- Incorporate existing libraries into your game to add extra functionality such as hardware integration
- Implement AI tasks and behaviors in Blueprints and C++
- Generate data to control the appearance and content of UI elements
In Detail
Unreal Engine 4 (UE4) is a complete suite of game development tools made by game developers, for game developers. With more than 100 practical recipes, this book is a guide showcasing techniques to use the power of C++ scripting while developing games with UE4. It will start with adding and editing C++ classes from within the Unreal Editor. It will delve into one of Unreal's primary strengths, the ability for designers to customize programmer-developed actors and components. It will help you understand the benefits of when and how to use C++ as the scripting tool. With a blend of task-oriented recipes, this book will provide actionable information about scripting games with UE4, and manipulating the game and the development environment using C++. Towards the end of the book, you will be empowered to become a top-notch developer with Unreal Engine 4 using C++ as the scripting language.
Style and approach
A recipe based practical guide to show you how you can leverage C++ to manipulate and change your game behavior and game design using Unreal Engine 4.
Table of contents
-
Unreal Engine 4 Scripting with C++ Cookbook
- Table of Contents
- Unreal Engine 4 Scripting with C++ Cookbook
- Credits
- About the Authors
- About the Reviewer
- www.PacktPub.com
- Preface
-
1. UE4 Development Tools
- Introduction
- Installing Visual Studio
- Creating and building your first C++ project in Visual Studio
- Changing the code font and color in Visual Studio
- Extension – changing the color theme in Visual Studio
- Formatting your code (Autocomplete settings) in Visual Studio
- Shortcut keys in Visual Studio
- Extended mouse usage in Visual Studio
- UE4 – installation
- UE4 – first project
- UE4 – creating your first level
- UE4 – logging with UE_LOG
- UE4 – making an FString from FStrings and other variables
- Project management on GitHub – getting your Source Control
- Project management on GitHub – using the Issue Tracker
- Project management on VisualStudio.com – managing the tasks in your project
- Project management on VisualStudio.com – constructing user stories and tasks
-
2. Creating Classes
- Introduction
- Making a UCLASS – deriving from UObject
- Creating a user-editable UPROPERTY
- Accessing a UPROPERTY from Blueprints
- Specifying a UCLASS as the type of a UPROPERTY
- Creating a Blueprint from your custom UCLASS
- Instantiating UObject-derived classes (ConstructObject < > and NewObject < >)
- Destroying UObject-derived classes
- Creating a USTRUCT
- Creating a UENUM( )
- Creating a UFUNCTION
-
3. Memory Management and Smart Pointers
- Introduction
- Unmanaged memory – using malloc( )/free( )
- Unmanaged memory – using new/delete
- Managed memory – using NewObject< > and ConstructObject< >
- Managed memory – deallocating memory
- Managed memory – smart pointers (TSharedPtr, TWeakPtr, TAutoPtr) to track an object
- Using TScopedPointer to track an object
- Unreal's garbage collection system and UPROPERTY( )
- Forcing garbage collection
- Breakpoints and stepping through code
- Finding bugs and using call stacks
- Using the Profiler to identify hot spots
-
4. Actors and Components
- Introduction
- Creating a custom Actor in C++
- Instantiating an Actor using SpawnActor
- Destroying an Actor using Destroy and a Timer
- Destroying an Actor after a delay using SetLifeSpan
- Implementing the Actor functionality by composition
- Loading assets into components using FObjectFinder
- Implementing the Actor functionality by inheritance
- Attaching components to create a hierarchy
- Creating a custom Actor Component
- Creating a custom Scene Component
- Creating a custom Primitive Component
- Creating an InventoryComponent for an RPG
- Creating an OrbitingMovement Component
- Creating a building that spawns units
-
5. Handling Events and Delegates
- Handling events implemented via virtual functions
- Creating a delegate that is bound to a UFUNCTION
- Unregistering a delegate
- Creating a delegate that takes input parameters
- Passing payload data with a delegate binding
- Creating a multicast delegate
- Creating a custom Event
- Creating a Time of Day handler
- Creating a respawning pickup for an First Person Shooter
-
6. Input and Collision
- Introduction
- Axis Mappings – keyboard, mouse and gamepad directional input for an FPS character
- Axis Mappings – normalized input
- Action Mappings – one button responses for an FPS character
- Adding Axis and Action Mappings from C++
- Mouse UI input handling
- UMG keyboard UI shortcut keys
- Collision – letting objects pass through one another using Ignore
- Collision – picking up objects using Overlap
- Collision – preventing interpenetration using Block
-
7. Communication between Classes and Interfaces
- Introduction
- Creating a UInterface
- Implementing a UInterface on an object
- Checking if a class implements a UInterface
- Casting to a UInterface implemented in native code
- Calling native UInterface functions from C++
- Inheriting UInterface from one another
- Overriding UInterface functions in C++
- Exposing UInterface methods to Blueprint from a native base class
- Implementing UInterface functions in Blueprint
- Creating C++ UInterface function implementations that can be overridden in Blueprint
- Calling Blueprint-defined interface functions from C++
- Implementing a simple interaction system with UInterfaces
-
8. Integrating C++ and the Unreal Editor
- Introduction
- Using a class or struct as a blueprint variable
- Creating classes or structs that can be subclassed in Blueprint
- Creating functions that can be called in Blueprint
- Creating events that can be implemented in Blueprint
- Exposing multi-cast delegates to Blueprint
- Creating C++ enums that can be used in Blueprint
- Editing class properties in different places in the editor
- Making properties accessible in the Blueprint editor graph
- Responding to property – changed events from the editor
- Implementing a native code Construction Script
- Creating a new editor module
- Creating new toolbar buttons
- Creating new menu entries
- Creating a new editor window
- Creating a new Asset type
- Creating custom context menu entries for Assets
- Creating new console commands
- Creating a new graph pin visualizer for Blueprint
- Inspecting types with custom Details panels
-
9. User Interfaces – UI and UMG
- Introduction
- Drawing using Canvas
- Adding Slate Widgets to the screen
- Creating screen size-aware scaling for the UI
- Displaying and hiding a sheet of UMG elements in-game
- Attaching function calls to Slate events
- Use Data Binding with Unreal Motion Graphics
- Controlling widget appearance with Styles
- Create a custom SWidget/UWidget
- 10. AI for Controlling NPCs
- 11. Custom Materials and Shaders
-
12. Working with UE4 APIs
- Introduction
- Core/Logging API – Defining a custom log category
- Core/Logging API – FMessageLog to write messages to the Message Log
- Core/Math API – Rotation using FRotator
- Core/Math API – Rotation using FQuat
- Core/Math API – Rotation using FRotationMatrix to have one object face another
- Landscape API – Landscape generation with Perlin noise
- Foliage API – Adding trees procedurally to your level
- Landscape and Foliage API – Map generation using Landscape and Foliage APIs
- GameplayAbilities API – Triggering an actor's gameplay abilities with game controls
- GameplayAbilities API – Implementing stats with UAttributeSet
- GameplayAbilities API – Implementing buffs with GameplayEffect
- GameplayTags API – Attaching GameplayTags to an Actor
- GameplayTasks API – Making things happen with GameplayTasks
- HTTP API – Web request
- HTTP API – Progress bars
- Index
Product information
- Title: Unreal Engine 4 Scripting with C++ Cookbook
- Author(s):
- Release date: October 2016
- Publisher(s): Packt Publishing
- ISBN: 9781785885549
You might also like
book
Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
Write efficient, reusable scripts to build custom characters, game environments, and control enemy AI Key Features …
book
Beginning Unreal Engine 4 Blueprints Visual Scripting: Using C++: From Beginner to Pro
Discover how Unreal Engine 4 allows you to create exciting games using C++ and Blueprints. This …
book
Hands-On C++ Game Animation Programming
Learn animation programming from first principles and implement modern animation techniques that can be integrated into …
book
Beginning C++ Game Programming - Second Edition
Get to grips with programming techniques and game development using C++ libraries and Visual Studio 2019 …