Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
As usual, we need to create a delegate inside our Pickup that our Spawner can subscribe to so that it knows when the player collects the pickup. The Pickup also contains a Static mesh as a visual representation, and a RotatingMovementComponent so that the mesh will spin as a way to attract the attention of the players. Inside the Pickup constructor, we load one of the engine's inbuilt meshes as our visual representation. We specify that the mesh will overlap with other objects, then set the rotation rate of our mesh at 10 units per second in the X and Z axes. When the player overlaps the Pickup, it fires off its PickedUp delegate from the first step.
The PickupSpawner used
a Scene component to specify where to spawn the pickup ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access