Download

Intelligent Camera focus system

I’m trying to prepare a camera system for my motorcycle game. It requires a secondary camera component to move location/rotation in order to keep both the player and the target in frame (up a limit, forwards visibility is still required). When hitting the focus key, it should check to see if any suitable targets are within range. If there are, then it should make the nearest focus target and then orientate the camera on it. Subsequent presses of the focus input should focus on each of the next nearest targets and move the camera into a suitable position. Once all targets have been viewed, the final focus press should reactivate the starting camera.

So far I have tried to prepare a function which adds all actors which implement a certain interface into an array (if they are within the minimum target distance). You can see the basic process here:

9e58b6fc986e90755ed5fd6f360250cbb8cd0098.png

Focus_Player2.png

I feel like there’s probably some problems in here but I’m more focused on the second section at the moment.

In my camera component blueprint, I am trying to update the rotation based on the location of the focus target. I’m using the node “Find look at Rotation”. You can see my method here:

d7d895267c2c43498c39e841a0ae5bb9e2fb009d.png

When I activate my focus camera the initial movement seems correct, it centres on the target quickly. But then it doesn’t seem to stop rotating. I need to restrict the movement so that the camera does not move beyond certain values (to allow the player to see obstacles infront on him/her).

Does anyone see anything I doing wrong obviously? Or have any suggestions to how I might improve the focus target array building. This feels like a more complex feature than I’ve made before and I’d apprecaite the advice.

You’re adding rotation to the camera every tick. So its going to continue rotating the camera as long as Delta Rotation is > 0. Replace AddWorldRotation with SetWorldRotation. You can also replace RInterp To with RInterp To Constant if you want. That will make the rotation a constant speed instead of being fast when the two rotations are far apart and super slow when they are close. If you want more control of the rotation speed/curve, you can use a Timeline instead of tick and create a float curve for the Interp Speed.

Cheers dude, thanks for spotting that. I’m close to wrapping up a first pass of this system. I’ll post it on here once I’m done.