In UEFN (Unreal Editor for Fortnite), you can use the Control Rig system to create aim/look-at functionality that tracks players. The primary node used for this purpose is the "Aim" node, which allows objects to orient toward specific targets.
Setting Up Player Tracking in Control Rig
To create a system that tracks players using Control Rig in UEFN, you'll need to follow these steps:
Creating the Control Rig
-
Create a Control Rig by right-clicking in your Content Browser, navigating to Animation > Control Rig, and creating a blank Control Rig[9].
-
In your Control Rig, create a control that will serve as your target (often called "Target Aim" or similar)[10].
-
Set up the Aim node by:
- Selecting the bone you want to aim (like a head, spine, or weapon)[10]
- Configuring the primary axis (the direction the object should point)[10]
- Setting up the secondary axis (to control rotation)[10]
-
Create a variable in your Control Rig to store the target location (typically a Vector type)[10].
-
Expose this variable by enabling "Expose on Spawn" and "Instance Editable" in the variable properties[10].
Connecting to Player Location in Verse
The key to tracking players is updating the target location variable with player position data from Verse:
-
In your Verse code, you'll need to:
- Track player positions (either the nearest player or a specific player)
- Update the Control Rig's target location variable with this position[9][7]
-
For tracking a specific player, you would:
- Get the player's actor location
- Set this as the target location for your Control Rig[7]
-
For tracking the nearest player, you would:
- Loop through all players
- Calculate distances
- Select the closest one
- Update the target location with their position
Important Considerations
When implementing this system, keep these technical details in mind:
-
Space Transformation: You must transform world space coordinates to rig space. Use the "From World" node to convert player world positions to the rig's local space[10].
-
Axis Configuration: Make sure to configure the primary and secondary axes correctly based on your model's orientation[10].
-
Rotation Constraints: You may want to limit rotation on certain axes to prevent unnatural movement[10].
Implementation Example
Here's a simplified approach based on existing implementations:
-
In your Control Rig:
// In the Forward Solve graph
// Create a sequence node
// Get your target aim control
// Set its translation using the Target Location variable
// Use From World node to convert from world space to rig space
// Connect this to your Aim node
-
In your Animation Blueprint:
- Add a Control Rig node
- Select your Control Rig class
- Expose the Target Location pin
- Update this location in the Event Blueprint Update Animation event[7]
-
In your Verse code:
- On tick or appropriate event
- Get player location
- Update the Control Rig's target location
This approach has been successfully used in projects like the Rex Run Island, where a camera smoothly follows player movement using Control Rig interpolation[6], and in various combat mechanics where enemies aim at players[7][10].
By combining these techniques, you can create NPCs or objects that realistically track and aim at players in your UEFN projects.