Download

Change Spring Arm Adjustement after Collision Test

I want to change the ammount a spring arm component adjusts the camera after performing a collision test.

For example, when my camera collides against a wall (so the collision test performed is successful) the spring arm adjusts the camera on top of the player’s head.
Is there a way to tweak this a bit to make it adjust it a bit further back and less on top?

Are you trying to post process the adjusted spring arm location? If so, then override the UpdateDesiredArmLocationmethod


void MySpringArmComponent::UpdateDesiredArmLocation
(
    bool bDoTrace,
    bool bDoLocationLag,
    bool bDoRotationLag,
    float DeltaTime
)
{
    Super::UpdateDesiredArmLocation(bDoTrace, bDoLocationLag, bDoRotationLag, DeltaTime);

    // Spring arm should be adjusted now, you can further adjust it below
}


Alternatively, you can override the BlendLocation. When the spring arm detects a collision, it calls this method passing in the DesiredArmLocation (without collision) and the HitLocation and whether it is a blocking hit. By default, if a blocking hit is found, it returns HitLocation so that the UpdateDesiredArmLocation method can use it as a final target location.

Instead of selecting either the DesiredArmLocation or HitLocation based on a hit detection, you can implement custom logic to return something in between, or anything tweaked in fact.