Set Actor Location not working, but working only when I am in Air!

Set Actor Location only happens in air (example jump), not when I am walking on ground.

I am using Gameplay Ability System (I hate it) and sending target data to “blink” to:

void UGA_BLINK::perform_ability(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo * ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData * TriggerEventData)
{
	if (!(ActorInfo->AvatarActor.Get())) return;

	AActor * avatar_actor_ = ActorInfo->AvatarActor.Get();

	// Server: Receive Target Data from client
	// if (ActorInfo->IsNetAuthority())
	if (HasAuthority(&ActivationInfo))
	{
		if (ActorInfo->IsLocallyControlled())
		{
			avatar_actor_->SetActorLocation(
				get_target_data(avatar_actor_).Location
			);

			EndAbility(Handle, ActorInfo, ActivationInfo, true, false);
			return;
		}

		ActorInfo->AbilitySystemComponent.Get()
			->AbilityTargetDataSetDelegate(
				Handle,
				ActivationInfo.GetActivationPredictionKey()
			)
				.AddLambda(		// Binding Listener handler
					[this, avatar_actor_, Handle, ActorInfo, ActivationInfo]
						(const FGameplayAbilityTargetDataHandle& Data, FGameplayTag Tag)
					{
						if (!(
							// Data.IsValid(0) && 
							Data.Get(0) && 
							Data.Get(0)->GetHitResult()
						))
						{
							CancelAbility(Handle, ActorInfo, ActivationInfo, true);
							return;
						}

						GEngine->AddOnScreenDebugMessage(
							-1,
							5.0f,
							FColor::Emerald,
							FString::Printf(
								TEXT("BLINK >>> %s: Moving %s to %s"),
								HasAuthority(&ActivationInfo) ? TEXT("SERVER") : TEXT("CLIENT"),
								*avatar_actor_->GetName(),
								*Data.Get(0)->GetHitResult()->Location.ToString()
							)
						);

						// Set Actor Location
						avatar_actor_->SetActorLocation(Data.Get(0)->GetHitResult()->Location);

						EndAbility(Handle, ActorInfo, ActivationInfo, true, false);
					}
				);
	}
	else
	{
		// Client/Server: Send Target Data to server
		FScopedPredictionWindow ScopedPrediction(ActorInfo->AbilitySystemComponent.Get());

		FGameplayAbilityTargetDataHandle DataHandle;
		FGameplayAbilityTargetData_SingleTargetHit * Data = new FGameplayAbilityTargetData_SingleTargetHit();
		Data->HitResult = get_target_data(avatar_actor_);
		DataHandle.Add(Data);

		GEngine->AddOnScreenDebugMessage(
			-1,
			5.0f,
			FColor::Emerald,
			FString::Printf(
				TEXT("BLINK >>> %s: sending target location"),
				HasAuthority(&ActivationInfo) ? TEXT("SERVER") : TEXT("CLIENT")
			)
		);

		ActorInfo->AbilitySystemComponent.Get()
			->ServerSetReplicatedTargetData(
				Handle,
				ActivationInfo.GetActivationPredictionKey(),
				DataHandle,
				TriggerEventData->EventTag,
				ActorInfo->AbilitySystemComponent.Get()->ScopedPredictionKey
			);

		EndAbility(Handle, ActorInfo, ActivationInfo, true, false);
	}
}

The client sends data to server. But the client only blinks to location when in Air!

Same thing with the server, where I am not listening for target data and simply setting Actor Location. Server only sets actor location when in Air.

What am I doing wrong? Please help!

Ok, it is now working! I used draw debug to see where the hit location was.

Turns out, when actor landed, the debug collision drew around the actor, with start-end locations being actor - Camera range location.

So when character landed, the capsule trace updated the hit location to actor location due to camera trace collision with the ground!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.