Why wouldn't getting data from pointer work

First one: the 300.0f() looks strange to me - use 300.0f instead, the parentheses typically indicate functions. So it should work, if CameaBoom variable is a pointer to a SpringArm Component, and if this pointer points to valid data by doing this in the constructor:

CameraBoom = CreateDefaultSubobject(TEXT("SpringArmComp"));

The CreateDefaultSubobject function returns the pointer the SpringArmComponent.
If CameraBoom is a valid pointer, *CameraBoom is used to access the contents this pointer points to, means the spring arm object itself. If at this memory location a valid spring arm object has been created (see above), the second code should work as well.

Hi Im very new to c++ programming so I had a question about pointer

I was wondering why this would work
CameraBoom->TargetArmLength = 300.0f();

and this wouldn’t

auto variable = *CameraBoom;
variable.TargetArmLength = 300.0f;

When you do this :

auto variable = *CameraBoom;

It translates to this :

USpringArmComponent variable = *CameraBoom;

Which is a shortcut for this :

USpringArmComponent variable;
variable = *CameraBoom;
// or

The first line is effectively allocating a new object of type USpringArmComponent with the default constructor. The second line is calling the copy operator on the new object, using CameraBoom as copy source.

So your variable here does not contain the same object as CameraBoom. It is a new, temporary object, that is not registered with anything, and will be destructed as soon as execution leaves that scope (the function).

You can theoretically do what you want using a reference instead of a plain object variable :

USpringArmComponent& variable = *CameraBoom; // auto& variable = *CameraBoom;
variable.TargetArmLength = 300.f;

Reference is like pointer but needs to be initialized with a valid object, and can only be initialized once. Afterwards it is used just like a plain object, so it is not possible to re-assign it, as using operator = on it will call the copy operator (not re-point the reference).

I’ve seen it in the engine code once, but it’s very unusual.