# How to check whether an Input Action made in Blueprints is triggered (or grabs the value) from a C++ class that doesn't handle input for MOBA style ability indicator

**URL:** <https://forums.unrealengine.com/t/how-to-check-whether-an-input-action-made-in-blueprints-is-triggered-or-grabs-the-value-from-a-c-class-that-doesnt-handle-input-for-moba-style-ability-indicator/1224474>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, UE5, Blueprint, CPP, question\
**Created:** [July 10, 2023, 1:40am UTC](https://forums.unrealengine.com/t/how-to-check-whether-an-input-action-made-in-blueprints-is-triggered-or-grabs-the-value-from-a-c-class-that-doesnt-handle-input-for-moba-style-ability-indicator/1224474 "2023-07-10T01:40:18Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![xeryvelgarde](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xeryvelgarde](https://forums.unrealengine.com/u/xeryvelgarde)\
**Post date:** [July 15, 2023, 8:11pm UTC](https://forums.unrealengine.com/t/how-to-check-whether-an-input-action-made-in-blueprints-is-triggered-or-grabs-the-value-from-a-c-class-that-doesnt-handle-input-for-moba-style-ability-indicator/1224474/9 "2023-07-15T20:11:30Z")

</div>

Thank you for your detailed explanation as well as the documentation. It makes a lot of sense now. I’m curious about your thoughts on what’s written below, on whether this is the right logic.

I’m trying to learn how to do a system similar to Atlas Reactor but singleplayer (no way in heck can I do multiplayer at my skill level), the game has multiple phases, decision → prep → dash → blast → move, where all abilities happen simultaneously, but they have different phases and will activate during those phases.

My idea was to have a class that handles the turn queue (not sure what it would inherit from, `GameModeBase`? Then use that class, make delegates then bind them to the corresponding abilities. And then maybe have a function somewhere like:

```auto
{
	switch (AbilityPhase)
	{
	case EPhase::Prep:
		TurnQueue->OnPrepSignature.AddDynamic(this, &UAbilityComponent::Resolution);
		break;
	case EPhase::Dash:
		TurnQueue->OnDashSignature.AddDynamic(this, &UAbilityComponent::Resolution);
		break;
	case EPhase::Blast:
		TurnQueue->OnBlastSignature.AddDynamic(this, &UAbilityComponent::Resolution);
		break;
	case EPhase::Move:
		TurnQueue->OnBlastSignature.AddDynamic(this, &UAbilityComponent::Resolution);
		break;
	}
}

```

But I guess this system would be a subsystem? I already made sure to have two `IMC` that I’ll switch out for ‘Atlas Reactor mode’ and normal mode.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/c/3fcb1ae45b3032e0b34a1a7572f0d4ff114e15ed.jpeg "Atlas Reactor #80 | The Last Game of Atlas Reactor") ](https://www.youtube.com/watch?v=TWvasiuZrEI)

I also just realised, I wouldn’t actually even need to use `SetTimer()` inside of `UAbilityComponent` itself to check where to put the indicator (while you’re in decision mode). Because presumably in the decision mode, you’d have a timer that’s counting down, from the class that handles the turns, you’ll set the timer in there to check your mouse movement and choices.

This

> [@xeryvelgarde](#):
>
> ```auto
> 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();
> }
> }
> 
> ```

would instead all be handled by `APawn/ACharacter`/`AController` since you said only pawns can have controllers.

```auto
FVector UAbilityComponent::GetPlayerCursorLocation() const
{
	FHitResult HitResult;
	GetWorld()->GetFirstPlayerController()->GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, HitResult);
	return HitResult.Location;
}

void UAbilityComponent::SetIndicatorDecalAtLocation()
{
	if (GetOwner() == nullptr || IndicatorDecalComponent == nullptr)
		return;

	FVector PlayerCursorLocation = GetPlayerCursorLocation();
	// Cự ly của indicator nên tương đối, 0 là địa điểm của nhân vật
	FVector PlayerCharacterLocation = GetOwner()->GetActorLocation();

	if (FVector::Dist(PlayerCursorLocation, PlayerCharacterLocation) > GetAbilityRange())
	{
		FHitResult Hit;
		FVector End = PlayerCharacterLocation + UKismetMathLibrary::FindLookAtRotation(PlayerCharacterLocation, PlayerCursorLocation).Vector() * GetAbilityRange();
		const FCollisionQueryParams CollisionQueryParams;
		const FCollisionResponseParams CollisionResponseParams;

		GetWorld()->LineTraceSingleByChannel(Hit, PlayerCharacterLocation, End, ECollisionChannel::ECC_Visibility, CollisionQueryParams, CollisionResponseParams);

		PlayerCursorLocation = Hit.Location;
	}

	IndicatorDecalComponent->SetWorldLocation(PlayerCursorLocation);
}

```

`SetIndicatorDecalAtLocation()` would be inside of the `UAbilityComponent` though and so would the `UDecalComponent`, I think. To me it doesn’t really make sense it would be attached to the character if it changes based on what ability it is.

  
I do have one problem though when I was trying to test setting my indicator, I can’t figure out though why it’s not setting the decal component in the world correctly when I move my mouse around, if the range is `0.0` it should be below the character. I have a timer that checks `SetIndicatorDecalAtLocation()` every `0.35` seconds and it runs. I was looking at the top down template for 4.27 and it was only adding a decal component to the character itself, not sure if that’s what’s causing the issue.

If I click on a specific spot it shows the decal but it doesn’t look right (should be circular). I can’t grab the decal component and reposition it despite it being editable anywhere (public), so I’m not sure if that’s the issue. I also tried adding a `USceneComponent` then attached the decal component to it, still can’t move either of them.

> [@C++ Components with sub components](https://forums.unrealengine.com/t/c-components-with-sub-components/406455/2):
>
> Yes, make scene component. One of features of scene components if fact that it can contain other scene components, this action is called attaching. Make that Port component and that port component code will attach static mesh component to it self to define there apperance. Alternatively you can extend from UStaticMeshComponent and just set mesh and add game play code to it, it should display mesh normally and execute that extra code. But first option let developer to modify appearance of co…

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/8/738b83f780f01415a083f2c76910a37e6e404714.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/f/c0f35881461b20c4625c036c5d2c7708655286fd.png)  
Mhm, I am confused why it would call `PostInitializeComponents()` in this situation. From what I understand in BP, when you add a component on the side, it’s the equivalent of `CreateDefaultSubobject` in C++ inside the constructor, so shouldn’t it be `InitializeComponents()`? Thank you, sorry for my late response, I got busy.

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-check-whether-an-input-action-made-in-blueprints-is-triggered-or-grabs-the-value-from-a-c-class-that-doesnt-handle-input-for-moba-style-ability-indicator/1224474)._
