本文整理汇总了C++中ACharacter::GetCapsuleComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ ACharacter::GetCapsuleComponent方法的具体用法?C++ ACharacter::GetCapsuleComponent怎么用?C++ ACharacter::GetCapsuleComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACharacter
的用法示例。
在下文中一共展示了ACharacter::GetCapsuleComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeSize
void UCheatManager::ChangeSize( float F )
{
APawn* Pawn = GetOuterAPlayerController()->GetPawn();
// Note: only works on characters
ACharacter *Character = Cast<ACharacter>(Pawn);
if (Character)
{
ACharacter* DefaultCharacter = Character->GetClass()->GetDefaultObject<ACharacter>();
Character->GetCapsuleComponent()->SetCapsuleSize(DefaultCharacter->GetCapsuleComponent()->GetUnscaledCapsuleRadius() * F, DefaultCharacter->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight() * F);
if (Character->GetMesh())
{
Character->GetMesh()->SetRelativeScale3D(FVector(F));
}
Character->TeleportTo(Character->GetActorLocation(), Character->GetActorRotation());
}
}
示例2: IsSpawnpointPreferred
bool ALabyrinthGameMode::IsSpawnpointPreferred(APlayerStart* SpawnPoint, AController* Player) const
{
ACharacter* MyPawn = Cast<ACharacter>((*DefaultPawnClass)->GetDefaultObject<ACharacter>());
// TO-DO: Add AI Controller
//ALAIController* AIController = Cast<ALAIController>(Player);
/*if (AIController != nullptr)
{
MyPawn = Cast<ACharacter>(BotPawnClass->GetDefaultObject<ACharacter>());
}*/
if (MyPawn)
{
const FVector SpawnLocation = SpawnPoint->GetActorLocation();
for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++)
{
ACharacter* OtherPawn = Cast<ACharacter>(*It);
if (OtherPawn && OtherPawn != MyPawn)
{
const float CombinedHeight = (MyPawn->GetCapsuleComponent()->GetScaledCapsuleHalfHeight() + OtherPawn->GetCapsuleComponent()->GetScaledCapsuleHalfHeight()) * 2.0f;
const float CombinedRadius = (MyPawn->GetCapsuleComponent()->GetScaledCapsuleRadius() + OtherPawn->GetCapsuleComponent()->GetScaledCapsuleRadius());
const FVector OtherLocation = OtherPawn->GetActorLocation();
// Check if the player start overlaps this pawn
if (FMath::Abs(SpawnLocation.Z - OtherLocation.Z) < CombinedHeight && (SpawnLocation - OtherLocation).Size2D() < CombinedRadius)
{
return false;
}
}
}
}
else
{
return false;
}
return true;
}
示例3: GetActorLocation
AActor * AHunterProjectile::FindHitActor()
{
const FVector &thisLocation = GetActorLocation();
UFlockingDataCache *cache = UFlockingDataCache::GetCacheChecked(this);
ACharacter *playerCharacter = nullptr;
for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; ++It)
{
AController *controller = *It;
APawn *otherPawn = controller->GetPawn();
if (otherPawn == nullptr)
{
continue;
}
if (controller->IsA(APlayerController::StaticClass()))
{
playerCharacter = Cast<ACharacter>(controller->GetPawn());
}
}
const TArray<FVector> &calfLocations = cache->GetTeamData(TEAM_CALVES)->m_locations;
const TArray<FVector> &playerLocations = cache->GetLocationsPlayer();
int32 targetCalf = FindHitActor(calfLocations, cache->GetTeamData(TEAM_CALVES)->m_agentRadius * 0.5f);
AActor *targetActor = nullptr;
if (targetCalf == INDEX_NONE)
{
int32 targetPlayer = FindHitActor(playerLocations, 0.5f * playerCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius());
if (targetPlayer != INDEX_NONE)
{
targetActor = playerCharacter;
}
}
else
{
targetActor = cache->GetOrCreateTeamData(TEAM_CALVES).m_agents[targetCalf];
}
return targetActor;
}
示例4: IsSpawnpointPreferred
bool ASGameMode::IsSpawnpointPreferred(APlayerStart* SpawnPoint, AController* Controller)
{
if (SpawnPoint)
{
/* Iterate all pawns to check for collision overlaps with the spawn point */
const FVector SpawnLocation = SpawnPoint->GetActorLocation();
for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; It++)
{
ACharacter* OtherPawn = Cast<ACharacter>(*It);
if (OtherPawn)
{
const float CombinedHeight = (SpawnPoint->GetCapsuleComponent()->GetScaledCapsuleHalfHeight() + OtherPawn->GetCapsuleComponent()->GetScaledCapsuleHalfHeight()) * 2.0f;
const float CombinedWidth = SpawnPoint->GetCapsuleComponent()->GetScaledCapsuleRadius() + OtherPawn->GetCapsuleComponent()->GetScaledCapsuleRadius();
const FVector OtherLocation = OtherPawn->GetActorLocation();
// Check if player overlaps the playerstart
if (FMath::Abs(SpawnLocation.Z - OtherLocation.Z) < CombinedHeight && (SpawnLocation - OtherLocation).Size2D() < CombinedWidth)
{
return false;
}
}
}
/* Check if spawnpoint is exclusive to players */
ASPlayerStart* MyPlayerStart = Cast<ASPlayerStart>(SpawnPoint);
if (MyPlayerStart)
{
return MyPlayerStart->GetIsPlayerOnly() && !Controller->PlayerState->bIsABot;
}
}
return false;
}