Create Custom Spring Arm Component

Hello Everyone!

I am currently learning C++ programming for UE4, being a programmer, I felt I was kinda cheating using BPs, so I am trying to reproduce all mechanics I had on my original BP project in C++.
One thing I always wanted for my game was the possibility to override the Spring Arm Component collision, so instead of drawing the camera closer, it would rotate the spring arm for a complete top down perspective (the game is kinda 45 degrees looking at the character, just like your typical old school RPG).

After a bit of struggling, I managed to do this via BP, using some workarouds, so the Spring Arm is not the one actually controlling the need for rotating (I created a BP extending from Actor, placed strategically in the level where view would be blocked, and it triggers the rotation of the Spring Arm on the Character, when he enters the volume). But I read somewhere that we can extend our components in C++ ourselves, so I went to do this guerilla style, by my own.

I actually created a new class, extending from USpringArmComponent, and was able to create my own version of BlendLocation (named BlendRotation), and to override the GetDesiredLocation, so that when the Line Trace hits something, it should rotate the spring arm for a 90 degree top view. I am not sure if it will work, because I had a lot of errors when trying to setup this component on my Character class. When I extended the Character class, it came with a predefined attribute for the Spring Arm and for the Camera. I tried switching this declaration, getter, and constructor from the USPringArmComponent to my UModernSpringArmComponent, but without success.

Sorry for not having any prints or code right now, as I am not writing from my PC, I should update with screens or snippets later.
For now, I would like to understand if:

  • Am I able to setup a custom Spring Arm Component? In positive case, how? How can I setup the Character for this trick? Is there another way to achieve what I want?

Thanks a lot for helping, this forum has killed a lot of doubts I had!