本文整理汇总了C++中ACharacter类的典型用法代码示例。如果您正苦于以下问题:C++ ACharacter类的具体用法?C++ ACharacter怎么用?C++ ACharacter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACharacter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAvatarActor
//TODO: This is still an awful way to do this and we should scrap this task or do it right.
void UAbilityTask_MoveToLocation::TickTask(float DeltaTime)
{
if (bIsFinished)
{
return;
}
Super::TickTask(DeltaTime);
AActor* MyActor = GetAvatarActor();
if (MyActor)
{
ACharacter* MyCharacter = Cast<ACharacter>(MyActor);
if (MyCharacter)
{
UCharacterMovementComponent* CharMoveComp = Cast<UCharacterMovementComponent>(MyCharacter->GetMovementComponent());
if (CharMoveComp)
{
CharMoveComp->SetMovementMode(MOVE_Custom, 0);
}
}
float CurrentTime = GetWorld()->GetTimeSeconds();
if (CurrentTime >= TimeMoveWillEnd)
{
bIsFinished = true;
// Teleport in attempt to find a valid collision spot
MyActor->TeleportTo(TargetLocation, MyActor->GetActorRotation());
if (!bIsSimulating)
{
MyActor->ForceNetUpdate();
OnTargetLocationReached.Broadcast();
EndTask();
}
}
else
{
float MoveFraction = (CurrentTime - TimeMoveStarted) / DurationOfMovement;
if (LerpCurve)
{
MoveFraction = LerpCurve->GetFloatValue(MoveFraction);
}
MyActor->SetActorLocation(FMath::Lerp<FVector, float>(StartLocation, TargetLocation, MoveFraction));
}
}
else
{
bIsFinished = true;
EndTask();
}
}
示例2: NativeUpdateAnimation
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
ACharacter* OwningPawn = Cast<ACharacter>(TryGetPawnOwner());
//const auto MovementComp = OwningPawn->GetMovementComponent();
if (OwningPawn) {
Speed = OwningPawn->GetVelocity().Size();
Jump = OwningPawn->GetVelocity().Z;
isFlying = OwningPawn->CharacterMovement->IsFalling();
}
}
示例3: switch
void ABatteryCollectorGameMode::HandleCurrentState(EBatteryPlayState NewState)
{
switch (NewState)
{
case EBatteryPlayState::EPlaying:
{
// spawn volumes active
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(true);
}
}
break;
case EBatteryPlayState::Ewon:
{
// spawn volumes inactive
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
}
}
break;
case EBatteryPlayState::EGameOver:
{
// spawn volumes inactive
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
}
// block player input
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (PlayerController)
{
PlayerController->SetCinematicMode(true, false, false, true, true);
}
// ragdoll the character
ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
if (MyCharacter)
{
MyCharacter->GetMesh()->SetSimulatePhysics(true);
MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
}
}
break;
default:
case EBatteryPlayState::EUnknown:
{
// Do nothing
}
break;
}
}
示例4: CancelAbility
/**
* Canceling an non instanced ability is tricky. Right now this works for Jump since there is nothing that can go wrong by calling
* StopJumping() if you aren't already jumping. If we had a montage playing non instanced ability, it would need to make sure the
* Montage that *it* played was still playing, and if so, to cancel it. If this is something we need to support, we may need some
* light weight data structure to represent 'non intanced abilities in action' with a way to cancel/end them.
*/
void UGameplayAbility_CharacterJump::CancelAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateCancelAbility)
{
if (ScopeLockCount > 0)
{
WaitingToExecute.Add(FPostLockDelegate::CreateUObject(this, &UGameplayAbility_CharacterJump::CancelAbility, Handle, ActorInfo, ActivationInfo, bReplicateCancelAbility));
return;
}
Super::CancelAbility(Handle, ActorInfo, ActivationInfo, bReplicateCancelAbility);
ACharacter * Character = CastChecked<ACharacter>(ActorInfo->AvatarActor.Get());
Character->StopJumping();
}
示例5: ActivateAbility
void UGameplayAbility_CharacterJump::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo)
{
if (ActivationInfo.ActivationMode == EGameplayAbilityActivationMode::Authority ||
ActivationInfo.ActivationMode == EGameplayAbilityActivationMode::Predicting)
{
if (!CommitAbility(Handle, ActorInfo, ActivationInfo))
{
return;
}
ACharacter * Character = CastChecked<ACharacter>(ActorInfo->AvatarActor.Get());
Character->Jump();
}
}
示例6: ActivateAbility
void UGameplayAbility_CharacterJump::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
if (HasAuthorityOrPredictionKey(ActorInfo, &ActivationInfo))
{
if (!CommitAbility(Handle, ActorInfo, ActivationInfo))
{
return;
}
ACharacter * Character = CastChecked<ACharacter>(ActorInfo->AvatarActor.Get());
Character->Jump();
}
}
示例7: ShouldTickPose
bool USkeletalMeshComponent::ShouldTickPose() const
{
// Characters playing Root Motion will tick pose themselves before physics.
ACharacter * CharacterOwner = Cast<ACharacter>(GetOwner());
const bool bSkipBecauseOfRootMotion = CharacterOwner && CharacterOwner->IsPlayingRootMotion();
// When we stop root motion we go back to ticking after CharacterMovement. Unfortunately that means that we could tick twice that frame.
// So only enforce a single tick per frame.
const bool bAlreadyTickedThisFrame = (LastTickTime == GetWorld()->TimeSeconds);
// Remote Clients on the Server will always tick animations as updates from the client comes in. To use Client's delta time.
const bool bRemoteClientOnServer = CharacterOwner && (CharacterOwner->Role == ROLE_Authority) && CharacterOwner->Controller && !CharacterOwner->Controller->IsLocalController();
return (Super::ShouldTickPose() && IsRegistered() && AnimScriptInstance && !bPauseAnims && GetWorld()->HasBegunPlay() && !bNoSkeletonUpdate && !bSkipBecauseOfRootMotion && !bRemoteClientOnServer && !bAlreadyTickedThisFrame);
}
示例8: GetOuterAPlayerController
void UCheatManager::Walk()
{
APawn* Pawn = GetOuterAPlayerController()->GetPawn();
if (Pawn != NULL)
{
ACharacter* Character = Cast<ACharacter>(Pawn);
if (Character)
{
Character->ClientCheatWalk();
if (!Character->IsLocallyControlled())
{
Character->ClientCheatWalk_Implementation();
}
}
}
}
示例9: OnDestroy
void UAbilityTask_ApplyRootMotionMoveToActorForce::OnDestroy(bool AbilityIsEnding)
{
if (MovementComponent)
{
MovementComponent->RemoveRootMotionSourceByID(RootMotionSourceID);
if (bSetNewMovementMode)
{
MovementComponent->SetMovementMode(NewMovementMode);
}
if (VelocityOnFinishMode == ERootMotionFinishVelocityMode::SetVelocity)
{
FVector EndVelocity;
ACharacter* Character = MovementComponent->GetCharacterOwner();
if (Character)
{
EndVelocity = Character->GetActorRotation().RotateVector(SetVelocityOnFinish);
}
else
{
EndVelocity = SetVelocityOnFinish;
}
// When we mean to SetVelocity when finishing a MoveTo, we apply a short-duration low-priority
// root motion velocity override. This ensures that the velocity we set is replicated properly
// and takes effect.
{
const FName OnFinishForceName = FName("AbilityTaskApplyRootMotionMoveToActorForce_EndForce");
FRootMotionSource_ConstantForce* ConstantForce = new FRootMotionSource_ConstantForce();
ConstantForce->InstanceName = OnFinishForceName;
ConstantForce->AccumulateMode = ERootMotionAccumulateMode::Override;
ConstantForce->Priority = 1; // Low priority so any other override root motion sources stomp it
ConstantForce->Force = EndVelocity;
ConstantForce->Duration = 0.001f;
MovementComponent->ApplyRootMotionSource(ConstantForce);
if (Ability)
{
Ability->SetMovementSyncPoint(OnFinishForceName);
}
}
}
}
Super::OnDestroy(AbilityIsEnding);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:47,代码来源:AbilityTask_ApplyRootMotionMoveToActorForce.cpp
示例10: GetShooterHUD
void AShooterPlayerController::OnDeathMessage(class AShooterPlayerState* KillerPlayerState, class AShooterPlayerState* KilledPlayerState, const UDamageType* KillerDamageType)
{
AShooterHUD* ShooterHUD = GetShooterHUD();
if (ShooterHUD)
{
ShooterHUD->ShowDeathMessage(KillerPlayerState, KilledPlayerState, KillerDamageType);
}
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
if (LocalPlayer && LocalPlayer->GetUniqueNetId().IsValid() && KilledPlayerState->UniqueId.IsValid())
{
// if this controller is the player who died, update the hero stat.
if (*LocalPlayer->GetUniqueNetId() == *KilledPlayerState->UniqueId)
{
const auto Events = Online::GetEventsInterface();
const auto Identity = Online::GetIdentityInterface();
if (Events.IsValid() && Identity.IsValid())
{
int32 UserIndex = LocalPlayer->ControllerId;
TSharedPtr<FUniqueNetId> UniqueID = Identity->GetUniquePlayerId(UserIndex);
if (UniqueID.IsValid())
{
ACharacter* Pawn = GetCharacter();
check(Pawn);
FVector Location = Pawn->GetActorLocation();
FOnlineEventParms Params;
Params.Add( TEXT( "SectionId" ), FVariantData( (int32)1 ) );
Params.Add( TEXT( "GameplayModeId" ), FVariantData( (int32)1 ) );
Params.Add( TEXT( "DifficultyLevelId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "PlayerRoleId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "PlayerWeaponId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "EnemyRoleId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "EnemyWeaponId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "LocationX" ), FVariantData( Location.X ) );
Params.Add( TEXT( "LocationY" ), FVariantData( Location.Y ) );
Params.Add( TEXT( "LocationZ" ), FVariantData( Location.Z ) );
Events->TriggerEvent(*UniqueID, TEXT("PlayerDeath"), Params);
}
}
}
}
}
示例11: switch
void ABatteryCollectorGameMode::HandleNewState(EBatteryPlayState NewState)
{
switch (NewState)
{
case EBatteryPlayState::EPlaying:
{
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(true);
}
}
break;
case EBatteryPlayState::EGameOver:
{
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
}
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (PlayerController)
{
PlayerController->SetCinematicMode(true, false, false, true, true);
}
ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
if (MyCharacter)
{
MyCharacter->GetMesh()->SetSimulatePhysics(true);
MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
}
}
break;
case EBatteryPlayState::EWon:
{
for (ASpawnVolume* Volume : SpawnVolumeActors)
{
Volume->SetSpawningActive(false);
}
}
break;
case EBatteryPlayState::EUnknown:
break;
default:
break;
}
}
示例12: GetAvatarActor
void UAbilityTask_MoveToLocation::OnDestroy(bool AbilityIsEnding)
{
AActor* MyActor = GetAvatarActor();
if (MyActor)
{
ACharacter* MyCharacter = Cast<ACharacter>(MyActor);
if (MyCharacter)
{
UCharacterMovementComponent* CharMoveComp = Cast<UCharacterMovementComponent>(MyCharacter->GetMovementComponent());
if (CharMoveComp && CharMoveComp->MovementMode == MOVE_Custom)
{
CharMoveComp->SetMovementMode(MOVE_Falling);
}
}
}
Super::OnDestroy(AbilityIsEnding);
}
示例13: UpdateAchievementProgress
void AShooterPlayerController::OnKill()
{
UpdateAchievementProgress(ACH_FRAG_SOMEONE, 100.0f);
const auto Events = Online::GetEventsInterface();
const auto Identity = Online::GetIdentityInterface();
if (Events.IsValid() && Identity.IsValid())
{
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
if (LocalPlayer)
{
int32 UserIndex = LocalPlayer->ControllerId;
TSharedPtr<FUniqueNetId> UniqueID = Identity->GetUniquePlayerId(UserIndex);
if (UniqueID.IsValid())
{
ACharacter* Pawn = GetCharacter();
// If player is dead, use location stored during pawn cleanup.
FVector Location = LastDeathLocation;
if (Pawn)
{
Pawn->GetActorLocation();
}
FOnlineEventParms Params;
Params.Add( TEXT( "SectionId" ), FVariantData( (int32)1 ) );
Params.Add( TEXT( "GameplayModeId" ), FVariantData( (int32)1 ) );
Params.Add( TEXT( "DifficultyLevelId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "PlayerRoleId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "PlayerWeaponId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "EnemyRoleId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "KillTypeId" ), FVariantData( (int32)0 ) );
Params.Add( TEXT( "LocationX" ), FVariantData( Location.X ) );
Params.Add( TEXT( "LocationY" ), FVariantData( Location.Y ) );
Params.Add( TEXT( "LocationZ" ), FVariantData( Location.Z ) );
Params.Add( TEXT( "EnemyWeaponId" ), FVariantData( (int32)0 ) );
Events->TriggerEvent(*UniqueID, TEXT("KillOponent"), Params);
}
}
}
}
示例14: 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;
}
示例15:
bool FMovieScene3DTransformSectionRecorderFactory::CanRecordObject(UObject* InObjectToRecord) const
{
if(USceneComponent* SceneComponent = Cast<USceneComponent>(InObjectToRecord))
{
// Dont record the root component transforms as this will be taken into account by the actor transform track
// Also dont record transforms of skeletal mesh components as they will be taken into account in the actor transform
bool bIsCharacterSkelMesh = false;
if (SceneComponent->IsA<USkeletalMeshComponent>() && SceneComponent->GetOwner()->IsA<ACharacter>())
{
ACharacter* Character = CastChecked<ACharacter>(SceneComponent->GetOwner());
bIsCharacterSkelMesh = SceneComponent == Character->GetMesh();
}
return (SceneComponent != SceneComponent->GetOwner()->GetRootComponent() && !bIsCharacterSkelMesh);
}
else
{
return InObjectToRecord->IsA<AActor>();
}
}