Unreal Engine 4 Scripting with C++ Cookbook: Get the best out of your games by scripting them using UE4

Unreal Engine 4 Scripting with C++ Cookbook: Get the best out of your games by scripting them using UE4

Unreal Engine 4 Scripting with C++ Cookbook: Get the best out of your games by scripting them using UE4
Автор: Sherif William, Whittle Stephen
Дата выхода: 2016
Издательство: Packt Publishing Limited
Количество страниц: 453
Размер файла: 5.1 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover....1

Copyright....3

Credits....4

About the Authors....5

About the Reviewer....6

www.PacktPub.com....7

Table of Contents....8

Preface....14

Chapter 1: UE4 Development Tools....20

Introduction....21

Installing Visual Studio....21

Creating and building your first C++ project in Visual Studio....23

Changing the code font and color in Visual Studio....27

Extension – changing the color theme in Visual Studio....30

Formatting your code (Autocomplete settings) in Visual Studio....34

Shortcut keys in Visual Studio....36

Extended mouse usage in Visual Studio....38

UE4 – installation....38

UE4 – first project....40

UE4 – creating your first level....41

UE4 – logging with UE_LOG....42

UE4 – making an FString from FStrings and other variables....44

Project management on GitHub – getting your Source Control....45

Project management on GitHub – using the Issue Tracker....47

Project management on VisualStudio.com – managing the tasks in your project....50

Project management on VisualStudio.com – constructing user stories and tasks....53

Chapter 2: Creating Classes....58

Introduction....59

Making a UCLASS – deriving from UObject....59

Creating a user-editable UPROPERTY....64

Accessing a UPROPERTY from Blueprints....66

Specifying a UCLASS as the type of a UPROPERTY....68

Creating a Blueprint from your custom UCLASS....70

Instantiating UObject-derived classes (ConstructObject < > & NewObject < >)....72

Destroying UObject-derived classes....74

Creating a USTRUCT....75

Creating a UENUM( )....77

Creating a UFUNCTION....77

Chapter 3: Memory Management and Smart Pointers....80

Introduction....81

Unmanaged memory – using malloc( )/free( )....81

Unmanaged memory – using new/delete....83

Managed memory – using NewObject< > and ConstructObject< >....84

Managed memory – deallocating memory....86

Managed memory – smart pointers (TSharedPtr, TWeakPtr, TAutoPtr) to track an object....87

Using TScopedPointer to track an object....88

Unreal's garbage collection system and UPROPERTY( )....89

Forcing garbage collection....90

Breakpoints and stepping through code....90

Finding bugs and using call stacks....92

Using the Profiler to identify hot spots....93

Chapter 4: Actors and Components....96

Introduction....96

Creating a custom Actor in C++....97

Instantiating an Actor using SpawnActor....101

Destroying an Actor using Destroy and a Timer....104

Destroying an Actor after a delay using SetLifeSpan....105

Implementing the Actor functionality by composition....106

Loading assets into components using FObjectFinder....108

Implementing the Actor functionality by inheritance....111

Attaching components to create a hierarchy....114

Creating a custom Actor Component....118

Creating a custom Scene Component....121

Creating a custom Primitive Component....125

Creating an InventoryComponent for an RPG....133

Creating an OrbitingMovement Component....144

Creating a building that spawns units....148

Chapter 5: Handling Events and Delegates....156

Handling events implemented via virtual functions....156

Creating a delegate that is bound to a UFUNCTION....159

Unregistering a delegate....162

Creating a delegate that takes input parameters....163

Passing payload data with a delegate binding....165

Creating a multicast delegate....167

Creating a custom Event....169

Creating a Time of Day handler....172

Creating a respawning pickup for an First Person Shooter....176

Chapter 6: Input and Collision....182

Introduction....182

Axis Mappings – keyboard, mouse and gamepad directional input for an FPS character....183

Axis Mappings – normalized input....185

Action Mappings – one button responses for an FPS character....187

Adding Axis and Action Mappings from C++....188

Mouse UI input handling....190

UMG Keyboard UI shortcut keys....191

Collision – letting objects pass through one another using Ignore....192

Collision – picking up objects using overlap....194

Collision – preventing interpenetration using Block....197

Chapter 7: Communication between Classes and Interfaces....200

Introduction....201

Creating a UInterface....201

Implementing a UInterface on an object....203

Checking if a class implements a UInterface....204

Casting to a UInterface implemented in native code....205

Calling native UInterface functions from C++....208

Inheriting UInterface from one another....213

Overriding UInterface functions in C++....217

Exposing UInterface methods to Blueprint from a native base class....221

Implementing UInterface functions in Blueprint....224

Creating C++ UInterface function implementations that can be overridden in Blueprint....227

Calling Blueprint-defined interface functions from C++....230

Implementing a simple interaction system with UInterfaces....235

Chapter 8: Integrating C++ and the Unreal Editor....244

Introduction....245

Using a class or struct as a blueprint variable....245

Creating classes or structs that can be subclassed in Blueprint....249

Creating functions that can be called in Blueprint....251

Creating events that can be implemented in Blueprint....255

Exposing multi-cast delegates to Blueprint....259

Creating C++ enums that can be used in Blueprint....268

Editing class properties in different places in the editor....275

Making properties accessible in the Blueprint editor graph....277

Responding to property – changed events from the editor....279

Implementing a native code "Construction Script"....282

Creating a new editor module....285

Creating new toolbar buttons....289

Creating new menu entries....297

Creating a new editor window....299

Creating a new Asset type....302

Creating custom context menu entries for Assets....306

Creating new console commands....313

Creating a new graph pin visualizer for Blueprint....319

Inspecting types with custom Details panels....325

Chapter 9: User Interfaces – UI and UMG....330

Introduction....330

Drawing using Canvas....331

Adding Slate Widgets to the screen....334

Creating screen size-aware scaling for the UI....338

Displaying and hiding a sheet of UMG elements in-game....344

Attaching function calls to Slate events....347

Use Data Binding with Unreal Motion Graphics....351

Controlling widget appearance with Styles....355

Create a custom SWidget/UWidget....362

Chapter 10: AI for Controlling NPCs....372

Introduction....372

Laying down a Navigation Mesh....373

Following behavior....373

Connecting a Behavior Tree to a Character....375

Constructing Task nodes....379

Using Decorators for conditions....380

Using periodic services....382

Using Composite nodes – Selectors, Sequences, and Simple Parallel....383

AI for a Melee Attacker....384

Chapter 11: Custom Materials and Shaders....386

Introduction....386

Modifying color using a basic Material....388

Modifying position using a Material....392

Shader code via Custom node....393

The Material function....396

Shader parameters and Material instances....398

Glimmer....399

Leaves and Wind....401

Reflectance dependent on the viewing angle....403

Randomness – Perlin noise....404

Shading a Landscape....405

Chapter 12: Working with UE4 APIs....408

Introduction....409

Core/Logging API – Defining a custom log category....410

Core/Logging API – FMessageLog to write messages to the Message Log....412

Core/Math API – Rotation using FRotator ....414

Core/Math API – Rotation using FQuat ....415

Core/Math API – Rotation using FRotationMatrix to have one object face another....417

Landscape API – Landscape generation with Perlin noise....419

Foliage API – Adding trees procedurally to your level....423

Landscape and Foliage API – Map generation using Landscape and Foliage APIs....425

GameplayAbilities API – Triggering an actor's gameplay abilities by game controls....427

GameplayAbilities API – Implementing stats with UAttributeSet....432

GameplayAbilities API – Implementing buffs with GameplayEffect....434

GameplayTags API – Attaching GameplayTags to an Actor....436

GameplayTasks API – Making things happen with GameplayTasks....438

HTTP API – Web request....440

HTTP API – Progress bars....443

Index....446

Unreal Engine 4 (UE4) is a complete suite of game development tools made by game developers for game developers. With more than 80 practical recipes, this book is a guide that showcases techniques to use the power of C++ scripting while developing games with UE4. We will start by adding and editing C++ classes from within the Unreal Editor. Then we will delve into one of Unreal's primary strengths—the ability for designers to customize programmer-developed actors and components. This will help you understand the benefits of when and how to use C++ as a 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++. Toward the end of this book, you will be empowered to become a top-notch developer with UE4 using C++ as the scripting language.


Похожее:

Список отзывов:

Нет отзывов к книге.