I am attempting to create an advanced movement component which extends from UCharacterMovementComponent that includes more options than just the default character movement. Upon calling the constructor when I create a subobject, the class uses a few getter functions, such as GetCharacterOwner()->GetWorld()->GetGravityZ(). When running the debugger to enter the editor, it calls __debugbreak() (unhandled exception) to cancel opening the editor, and says there’s an access violation. The memory address doesn’t return all zeros so it cannot be nullptr I believe (yet it is a low value).
Here’s the code snippet:
// constructor
UAdvancedMovementComponent::UAdvancedMovementComponent(const FObjectInitializer& foi) : Super(foi)
{
PrimaryComponentTick.bCanEverTick = true; // Tick every frame
gravDefault = GetCharacterOwner()->GetWorld()->GetGravityZ(); // Initial Gravity ( THE EXCEPTION IS THROWN HERE )
FTimerHandle handle;
GetCharacterOwner()->GetWorld()->GetTimerManager().SetTimer(handle, this, &UAdvancedMovementComponent::wallrunTick, 0.02f, true); // Start loop-checking for wallrunning
}
I will say I am new to using Unreal Engine, but please share your thoughts if you have any.
Thanks!