Skip to content

Instantly share code, notes, and snippets.

@michaeltchapman
Created October 9, 2018 05:39
Show Gist options
  • Save michaeltchapman/622316ac11156f3197a768b52b81f948 to your computer and use it in GitHub Desktop.
Save michaeltchapman/622316ac11156f3197a768b52b81f948 to your computer and use it in GitHub Desktop.
UAsyncAbilitySystemComponent* ASC = Cast<UAsyncAbilitySystemComponent>(AbilitySystemComponent);
if (ASC)
{
FGameplayAbilitySpec* Spec = BaseAbility->GetCurrentAbilitySpec();
if (Spec)
{
FMTargetingDefinition& Targeting = ASC->GetTargetingDefinition(Spec->InputID);
switch (Targeting.SpawnTransform)
{
case EMAbilitySpawnTransform::TargetAwaySource:
SpawnTransform = FTransform((LocationData->GetEndPoint() - LocationData->GetOrigin().GetTranslation()).ToOrientationQuat(), LocationData->GetEndPoint());
break;
case EMAbilitySpawnTransform::TargetToSource:
SpawnTransform = FTransform((LocationData->GetOrigin().GetTranslation() - LocationData->GetEndPoint()).ToOrientationQuat(), LocationData->GetEndPoint());
break;
case EMAbilitySpawnTransform::SourceAwayTarget:
SpawnTransform = FTransform((LocationData->GetOrigin().GetTranslation() - LocationData->GetEndPoint()).ToOrientationQuat(), LocationData->GetOrigin().GetTranslation());
break;
case EMAbilitySpawnTransform::SourceToTarget:
SpawnTransform = FTransform((LocationData->GetEndPoint() - LocationData->GetOrigin().GetTranslation()).ToOrientationQuat(), LocationData->GetOrigin().GetTranslation());
break;
case EMAbilitySpawnTransform::InstigatorToSource:
SpawnTransform = FTransform((LocationData->GetOrigin().GetTranslation() - Caster->GetActorLocation()).ToOrientationQuat(), Caster->GetActorLocation());
break;
case EMAbilitySpawnTransform::InstigatorToTarget:
SpawnTransform = FTransform((LocationData->GetEndPoint() - Caster->GetActorLocation()).ToOrientationQuat(), Caster->GetActorLocation());
break;
case EMAbilitySpawnTransform::InstigatorRotation:
SpawnTransform = FTransform(Caster->GetActorQuat(), Caster->GetActorLocation());
break;
case EMAbilitySpawnTransform::SourceToInstigator:
SpawnTransform = FTransform((Caster->GetActorLocation() - LocationData->GetOrigin().GetTranslation()).ToOrientationQuat(), LocationData->GetOrigin().GetTranslation());
break;
default: // TargetAwaySource
SpawnTransform = FTransform((LocationData->GetEndPoint() - LocationData->GetOrigin().GetTranslation()).ToOrientationQuat(), LocationData->GetEndPoint());
break;
}
Spell->SetTargetingData(LocationData->GetOrigin().GetTranslation(), LocationData->GetEndPoint(), ChargeTime, UniqueID);
bTransformSet = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment