Thank you, I think that makes sense to me. In this case, I think that if I were to implement what you were saying, I might have to modify it somewhat, and will definitely keep this in mind for refactoring. With PeekCurrent
, from what I understand, let’s say you have several abilities, and your container is an array, you can create a parameter that takes in the index and then call the correct ability from there, right?
I’m still slightly confused as to why BeforeAction()
and PostAction()
would be part of the character, and not the ability itself?
Let’s just say the ability has stages, you activate the ability, then BeforeAction()
would be called, let’s say to set up something, then next stage would be checking to see where the indicator is on screen (i.e. choosing where the ability would be activated) => then set the indicator which completes the action => then PostAction()
will occur, which is activating the effects of the ability.
I know you’re not trying to pigeonhole my design, , I’m just curious to this thought process further, trying to learn multiple techniques and mindsets. About
EReturnEnum
, would it be used to determine what ability is being activated? Or does it return whether an ability should be activated if at all.
I ended up finding out that you can grab the UEnhancedInputLocalPlayerSubsystem
in C++, so I’m curious if you can grab the value of an action that way. Expose the UInputAction
variable to BP, pass that UInputAction
in, grab UEnhancedInputLocalPlayerSubsystem
, then check the value of that constantly?
void UAbilityComponent::PreDecision_Implementation(UDecalComponent* NewIndicatorDecalComponent, const float& MaxIndicatorDistance, UInputAction* NewSetDestinationInputAction)
{
SetIndicatorDecalComponent(NewIndicatorDecalComponent);
SetAbilityRange(MaxIndicatorDistance);
SetSetDestinationInputAction(NewSetDestinationInputAction);
if (EnhancedInputLocalPlayerSubsystemSubsystem == nullptr)
{
EnhancedInputLocalPlayerSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetWorld()->GetFirstPlayerController()->GetLocalPlayer());
EnhancedPlayerInput = EnhancedInputLocalPlayerSubsystem->GetPlayerInput();
}
}
void UAbilityComponent::SetTimerOnDecision()
{
if (GetWorld())
GetWorld()->GetTimerManager().SetTimer(DecisionTimerHandle, this, &UAbilityComponent::OnDecision, 0.35f, true, 0);
}
void UAbilityComponent::OnDecision()
{
if (EnhancedPlayerInput == nullptr|| SetDestinationInputAction == nullptr) {
if (GetWorld())
GetWorld()->GetTimerManager().ClearTimer(DecisionTimerHandle);
return;
}
if (EnhancedPlayerInput->GetActionValue(SetDestinationInputAction).Get<bool>())
{
if (GetWorld())
GetWorld()->GetTimerManager().ClearTimer(DecisionTimerHandle);
SetTargetPosition(GetPlayerCursorLocation());
}
else
{
SetIndicatorDecalAtLocation();
}
}
I ended up trying to test that but for some reason, when I try to make a variable that references the subclass in BP inside of the player controller, it’s not valid, so it doesn’t run anything, do you have any idea as to why (sorry by the way, this has been something I’ve been having issues with, for instance I created a UMovementComponent
C++ class, add it to my character BP, it works there, but if I attempt to reference it inside the animation BP (grabbing it as a variable from my character BP), it’s null. I don’t know if it’s because I originally started with a BP template, then added C++ classes to it, instead of starting with a C++ template?
I was thinking of using OnComponentActivated
instead, but I don’t think that’ll do anything, I feel like I’m initialising my actor components in BP incorrectly somehow.
Thank you for your response by the way, I really appreciate it.