MothCocoon / FlowGraph

Design-agnostic node system for scripting game’s flow in Unreal Engine

Home Page:https://discord.gg/Xmtr6GhbmW

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Component Observer may continue triggering outputs if the last component triggered a finish during UFlowNode_ComponentObserver::StartObserving

PartlyAtomic opened this issue · comments

// node might finish work as the effect of triggering event on the found actor

Sorry for not doing this as a pull request, but I ended up making a very simple modification to the above section of code in a slightly older version of Flow Graph (the important part is just checking after ObserveActor() ).

		for (const TWeakObjectPtr<UFlowComponent>& FoundComponent : FlowSubsystem->GetComponents<UFlowComponent>(IdentityTags, EGameplayContainerMatchType::Any))
		{
			ObserveActor(FoundComponent->GetOwner(), FoundComponent);
			
			// node might finish work as the effect of triggering event on the found actor
			// we should terminate iteration in this case
			if (GetActivationState() != EFlowNodeState::Active) { return; }
		}

Hey @lfowles If I understand the issue correctly, the rest of UFlowNode_ComponentObserver::StartObserving() would be executed after the loop, so only binding to Flow Subystem methods?

If so, we shouldn't call ObserveActor in every case, as we would end up with a different issue which... we got plumbed back in August.

Shouldn't we have an additional check to prevent binding to delegates?
This is my proposed fix, what do you think?
423f293

This would also work, it's just constructed oddly with different return paths depending on which component triggers finish. If any of the 1..N-1 observed actors trigger a finish it'll return from the loop of registered components. Only if the Nth actor triggers a finish will it hit the branch you added.

This would also work, it's just constructed oddly with different return paths depending on which component triggers finish. If any of the 1..N-1 observed actors trigger a finish it'll return from the loop of registered components. Only if the Nth actor triggers a finish will it hit the branch you added.

Yes, the main benefit here, was supposed to be avoiding calling ObserveActor prior to checking a node state. But now I realize it was pointless, as we need at least one ObserveActor check to make this node inactive. I'm taking your change in, with a proper note in the release notes. Thanks! :)