Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
In the constructor for our Spotter object, we load one of the basic primitives, a cone, into our Static Mesh Component as a visual representation.
We then rotate the cone so that it resembles a spotlight pointing to the X axis of the actor.
During the Tick function, we get the actor's location and then find a point 200 units away from the actor along its local X axis. We call the parent class implementation of Tick using Super:: to ensure that any other tick functionality is preserved, despite our override.
We convert a local position into a world space position by first acquiring the Actor-to-World transform for the Actor, then using that to transform a vector specifying the position.
The transform is based on the orientation ...
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