Hi,
In my Top-Down ARPG, my main ACharacter
-subclass receives input through a APlayerController
-subclass and moves from A to B through point-and-click using UAIBlueprintHelperLibrary::SimpleMoveToLocation(PlayerController, Location)
. I’d like to implement a ACharacter::OnSimpleMoveToLocationEnd
to achieve:
- Left-Mouse-Click on item
- Go to item
- Pickup item.
My approach is:
// ATheCharacter.cpp
// TheCharacter::TheCharacter() { ...
AAIController* Controller = Cast<AAIController>(GetController());
UPathFollowingComponent* PathFollowingComponent = Controller->GetPathFollowingComponent();
// TheCharacter::BeginPlay() { ...
PathFollowingComponent->OnRequestFinished.AddUObject(this, &ATheCharacter::OnMoveCompleted);
// ATheCharacter.h
private:
void OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult& Result);
However, as expected AAIController* Controller = Cast<AAIController>(GetController());
this returns a nullptr
, because my ACharacter is obviously controlled by an APlayerController.
I don’t understand why it is possible to use UAIBlueprintHelperLibrary::SimpleMoveToLocation(PlayerController, Location)
with a non-AI APlayerController
.
My question is, how do I implement a ACharacter::OnSimpleMoveToLocationEnd
properly?
Thanks in advance!