Study Notes on Blueprint Data Types, Variables, and Arithmetic
Overview of Data Types and Variables
Introduction to data types and variables in Blueprints
Understanding how to access projects within Unreal Engine
Open projects through root directory:
Navigate to the drive, full self folder, the current month, and class
Locate and double-click the project file to open it safely to avoid duplicates
Accessing Unreal Projects
Importance of opening projects through the correct path
Prevents opening multiple copies of projects
Minimizes the risk of losing progress or mixing up working files
Events in Blueprints
Explanation of events within Unreal Engine
Each node with a red header signifies an event
Example: "Event Begin Play" initiates when the game starts and runs connected nodes
Understanding Variables and Data Types
Basic Data Types
Introduction to basic data types in Unreal
Explanation of Boolean values:
Definition: Represents abstract concepts of true/false
Not intended for arithmetic operations
Integer Types:
Regular Integer: Stores values approximately in the range of [-2^{31}, 2^{31}-1]
Byte: Stores small integers (0-255)
Int64: Can store very large integers, [−2^{63}, 2^{63} − 1]
Floats:
Represent real numbers, both whole and fractional
Comes in two precisions:
Single precision: 32-bit representation
Double precision: 64-bit representation
String Data Types
String is a sequence of characters:
Contains letters, numbers, punctuation, spaces
Specialized strings:
Name: Optimized for short strings to compare
Text: Facility for localization purposes (translation)
Composite Data Types
Vector: A grouping of three floats representing 3D space coordinates (X, Y, Z)
Rotator: Also consists of three floats, managing rotation in 3D space
Transform: Combination of two vectors and a rotator, representing location and orientation
Value Types vs. Reference Types
Explanation of value types:
Contain the actual data in the variable (e.g., numbers, booleans)
Explanation of reference types:
Contain memory addresses to objects rather than the objects themselves (e.g., actors)
Creating and Using Variables
What is a Variable?
A variable is a container for storing information (character stats, etc.)
Analogy: Cardboard box labeled and stored on shelves
Steps to Create a Variable:
Click plus button next to variables
Name the variable following Pascal case rules (no spaces, describe its value)
Choose the appropriate data type
Assign a value to the variable
Ways to Assign Values to Variables
At Runtime: Assigning value during gameplay
Example: Using "Set" node
Ensures that the value is available when needed
At Compile Time: Set default values through the details panel
Example: Use a default value before the game starts
Instance Editable: Allows the variable to be set in the level editor
Example: Editing variable values in particular instances of blueprints in the game environment
Retrieving Variable Values
Use the "Get" node to access current values
Distinction between get (retrieve value) and set (assign value)
May lead to confusion and improper coding practices
Blueprint Arithmetic
Introduction to Arithmetic Operators
Discussion of basic arithmetic operations:
Addition, Subtraction, Multiplication, Division
Modulus Operator: Finds remainder after division (denoted by %)
Order of Operations
Importance of adhering to mathematical principles
Example calculations to illustrate how Unreal Engine handles arithmetic
Division nuances:
Outcomes can differ based on integer or float contexts
Example distinctions between integer division (results in zero fractions) and float division (preserves decimals)
Implementing Movement via Variables and Arithmetic
Modifying Actor Rotation
Introduced a rotation speed based on delta time for consistent movement across varying frame rates
Variable for rotation speed set to 180 degrees per second
Ensured that rotation calculation takes frame rate into account:
Multiplies speed by delta seconds to achieve consistent rotation
Adjusting the actor's rotation every tick based on updated angle
Coding Best Practices
Importance of clean code and readable layouts
Understanding of inputs and outputs when working with nodes
Developer recommendations for common programming actions (e.g., increment and decrement operations)
Troubleshooting
How to handle common pitfalls encountered while coding within Unreal Engine
Tips on managing bugs and unexpected behavior
Conclusion:
Recap of main topics discussed
Prepare for hands-on coding practices and application of learned knowledge in the following classes