Unreal Engine 4 Scripting with C++ Cookbook

Get the best out of your games by scripting them using UE4
Preview in Mapt

Unreal Engine 4 Scripting with C++ Cookbook

William Sherif, Stephen Whittle

3 customer reviews
Get the best out of your games by scripting them using UE4
Mapt Subscription
FREE
โ‚ฌ29.98/m after trial
eBook
โ‚ฌ29.40
RRP โ‚ฌ41.98
Save 29%
Print + eBook
โ‚ฌ43.99
RRP โ‚ฌ43.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packtโ€™s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
โ‚ฌ0.00
โ‚ฌ29.40
โ‚ฌ43.99
โ‚ฌ29.99 p/m after trial
RRP โ‚ฌ41.98
RRP โ‚ฌ43.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Unreal Engine 4 Scripting with C++ Cookbook Book Cover
Unreal Engine 4 Scripting with C++ Cookbook
โ‚ฌ 41.98
โ‚ฌ 29.40
Unreal Engine 4 Scripting with C++ [Video] Book Cover
Unreal Engine 4 Scripting with C++ [Video]
โ‚ฌ 142.78
โ‚ฌ 121.38
Buy 2 for โ‚ฌ35.72
Save โ‚ฌ124.20
Add to Cart

Book Details

ISBN 139781785885549
Paperback452 pages

Book Description

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.

Table of Contents

Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 10: AI for Controlling NPCs
Introduction
Laying down a Navigation Mesh
Following behavior
Connecting a Behavior Tree to a Character
Constructing Task nodes
Using Decorators for conditions
Using periodic services
Using Composite nodes โ€“ Selectors, Sequences, and Simple Parallel
AI for a Melee Attacker
Chapter 11: Custom Materials and Shaders
Introduction
Modifying color using a basic Material
Modifying position using a Material
Shader code via Custom node
The Material function
Shader parameters and Material instances
Glimmer
Leaves and Wind
Reflectance dependent on the viewing angle
Randomness โ€“ Perlin noise
Shading a Landscape
Chapter 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

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

Authors

Table of Contents

Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 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
Chapter 10: AI for Controlling NPCs
Introduction
Laying down a Navigation Mesh
Following behavior
Connecting a Behavior Tree to a Character
Constructing Task nodes
Using Decorators for conditions
Using periodic services
Using Composite nodes โ€“ Selectors, Sequences, and Simple Parallel
AI for a Melee Attacker
Chapter 11: Custom Materials and Shaders
Introduction
Modifying color using a basic Material
Modifying position using a Material
Shader code via Custom node
The Material function
Shader parameters and Material instances
Glimmer
Leaves and Wind
Reflectance dependent on the viewing angle
Randomness โ€“ Perlin noise
Shading a Landscape
Chapter 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

Book Details

ISBN 139781785885549
Paperback452 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Unreal Engine: Game Development from A to Z Book Cover
Unreal Engine: Game Development from A to Z
โ‚ฌ 73.18
โ‚ฌ 51.24
Building an RPG with Unreal 4.x Book Cover
Building an RPG with Unreal 4.x
โ‚ฌ 43.18
โ‚ฌ 30.24
Beginning C++ Game Programming Book Cover
Beginning C++ Game Programming
โ‚ฌ 41.98
โ‚ฌ 29.40
Unreal Engine 4.X By Example Book Cover
Unreal Engine 4.X By Example
โ‚ฌ 41.98
โ‚ฌ 29.40
Procedural Content Generation for C++ Game Development Book Cover
Procedural Content Generation for C++ Game Development
โ‚ฌ 43.18
โ‚ฌ 30.24
Blender 3D: Characters, Machines, and Scenes for Artists Book Cover
Blender 3D: Characters, Machines, and Scenes for Artists
โ‚ฌ 73.18
โ‚ฌ 51.24