Hopefully this saves future adventurers through this class the trouble I went through:
I’m using Unreal 4.21 and taking this class for the first time. I was having trouble getting the assignment to PhysicsHandle working, so I dug into the documentation. It looks like the GetComponentByClass function is no longer templated, so in order to get it to compile and function correctly, my code now reads:
PhysicsHandle = (UPhysicsHandleComponent*)(
GetOwner()->GetComponentByClass(UPhysicsHandleComponent::StaticClass())
);
I’m not sure why they moved from a templated version (probably compile times?) but as a result, there is type-erasure (GetComponentByClass
returns a UActorComponent*
), hence why I am required to cast the result.