Customizing ECameraGroupActorComponent
Last updated
Last updated
ECameraGroupActorComponent is a component responsible for determining a group actor's location and rotation. You can override this component to customize your own way of location/rotation resolution.
Right click on Content Browser -> select "Blueprint Class" -> Search for "ECameraGroupActorComponent" -> click "Select".
Rename it as whatever you want. Here I name it MyGroupActorComponent. Open the blueprint class and you can see the "Functions" section on the left side of the blueprint window. There are several implementable functions in this section. For this component, you should implement the GetGroupActorLocation and GetGroupActorRotation functions, while other functions, if meet your needs, can also be implemented.
Below is a simple example using the location of the first target in variable TargetActors
as the group actor location. Note I am not calling the parent GetGroupActorLocation method because I would like to implement it from scratch. It is totally feasible to call the parent method if you need it.
Create a new ECameraGroupActor class. Right click on Content Browser -> select "Blueprint Class" -> Search for "ECameraGroupActor" -> click "Select". I name it MyGroupActor. Click the "CameraGroupActorComponent" on the left, and on the "Details" panel, change the "Component Class" property value to MyGroupActorComponent.
Drag the MyGroupActor blueprint into the level to instantiate a new group actor. Add two actors to the "Target Actors" property.
Back to the camera actor (of class ECameraBase
or sub-class of ECameraBase
), specify TargetingAim to the "Aim Component" property and specify ScreenFollow to the "Follow Component". Go to the blueprint where you want to call this camera. Invoke the CallCamera node and specify "Camera Class", "Follow Target" and "Aim Target". The passed in aim target should be the reference to the group actor you just created in level. You can also specify blending parameters if you like.
Run the game. You will see that camera is always aiming at the first target actor in "Target Actors".