Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unreal Engine 4 Game Development Quick Start Guide

You're reading from   Unreal Engine 4 Game Development Quick Start Guide Programming professional 3D games with Unreal Engine 4

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789950687
Length 202 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rachel Cordone Rachel Cordone
Author Profile Icon Rachel Cordone
Rachel Cordone
Arrow right icon
View More author details
Toc

Using C++ variables in Blueprint

Now that both our C++ class and Blueprint subclass are set up, we can take a look at how they can interact. First up, let's add a variable in C++ that we can use in Blueprint.

In our MyActor.h file in Visual Studio, we can add variables as we normally would. Unreal has a few custom variable types, such as using an FString instead of a standard string, but for now we'll just use a float.

If we simply declared a float in our header file, it would not be accessible in Blueprints. For that, we need to use a special UE4 macro, UPROPERTY. Using this, we can specify where and how our variable can be used. Most commonly, variables exposed to Blueprint need to be accessible anywhere (class defaults, in the Blueprint code itself, and in the level instance properties), as well as be readable and writable.

Let's add a float called TestFloat...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime