Book Image

Unreal Engine 4.X By Example

By : Benjamin Carnall
Book Image

Unreal Engine 4.X By Example

By: Benjamin Carnall

Overview of this book

With Unreal Engine 4 being made free to use, for any keen game developer it is quickly becoming the most popular game engine in today’s development industry. The engine offers a rich feature set that can be customized and built upon through the use of C++. This book will cover how to work with Unreal Engine’s tool set all the way from the basics of the editor and the visual scripting system blueprint to the in-depth low-level creation of content using C++. This book will provide you with the skills you need to create feature-rich, captivating, and refined game titles with Unreal Engine 4. This book will take you through the creation of four unique game projects, designed so that you will be ready to apply the engine’s rich development capabilities. You will learn not only to take advantage of the visual tools of the engine, but also the vast and powerful programming feature set of Unreal Engine 4.
Table of Contents (17 chapters)
Unreal Engine 4.X By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating the projectile


Now we have a player character and we have a cross hair, all we need now is something to shoot! We need to create an object that can be fired forward and act the same way a weighted projectile would under the effects of gravity, similar to a grenade or small cannon ball. We can do this by utilizing another movement-based component. This one is called a ProjectileMovementComponent and can be used alongside the physics engine to dictate how a projectile will move through space. Using the C++ class wizard create a class that inherits from Actor called BMProjectile.

Defining the Projectile

Let's start by defining the ABMProjectile class. We can begin with the private members of the class, navigate to BMProjectile.h and add the following code to the class definition under GENERATED_BODY():

/** Sphere collision component */
UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
class USphereComponent* ProjCollision;

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Projectile...