'nullptr crash in UE5, works perfectly fine with a different component

I apologize for the long post, I tried my best to remove as much code while providing what I think is relevant. I am using URotateObject in another C++ component, I can add it if needed.

I really don't see why this code would work for one component but not the other.

Visual Studio Is telling me this line is returning a null pointer

void URotateObject::SetShouldRotate(bool NewShouldRotate)
{
    ShouldRotate = NewShouldRotate;
}

Unhandled exception thrown: write access violation. this was nullptr.

I have nearly an identical component that isn't giving me problems at all

void UMover::SetShouldMove(bool NewShouldMove)
{
    ShouldMove = NewShouldMove;
}

Error I am getting from UE5 crash reporter

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x00000000000000dc


RotateObject.h

    public: 

        virtual void Tick...;
    
        void SetShouldRotate(bool ShouldRotate);

    private:

        UPROPERTY(EditAnywhere)
            bool ShouldRotate = false;
    

RotateObject.cpp

void tick...
{

    if (ShouldRotate)
    {
        FRotator NewRotation = FMath::RInterpConstantTo(CurrentRotation, TargetRotation, DeltaTime, RotateTime);
        GetOwner()->SetActorRotation(NewRotation);
    }
}

void URotateObject::SetShouldRotate(bool NewShouldRotate)
{
    ShouldRotate = NewShouldRotate;
}

Trigger.cpp

AActor* Actor = GetAcceptableActor();
    if (Actor != nullptr)
    {
        Mover->SetShouldMove(true);
        RotateObject->SetShouldRotate(true);
    }
    else
    {
        Mover->SetShouldMove(false);
        RotateObject->SetShouldRotate(false);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source