Creating an OrbitingMovement Component

This component is similar to RotatingMovementComponent in that it is designed to make the components parented to it move in a particular way. In this instance, it will move any attached components in an orbit around a fixed point at a fixed distance.

This could be used, for example, for a shield that orbits around a character in an Action RPG.

How to do it...

  1. Create a new SceneComponent subclass and add the following properties to the class declaration:
    bool RotateToFaceOutwards;
    float RotationSpeed;
    float OrbitDistance;
    float CurrentValue;
  2. Add the following to the constructor:
    RotationSpeed = 5;
    OrbitDistance = 100;
    CurrentValue = 0;
    RotateToFaceOutwards = true;
  3. Add the following ...

Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.