void AGameplayDebuggingReplicator::PostInitializeComponents() { Super::PostInitializeComponents(); #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) SetActorTickEnabled(true); #endif }
void AGameplayDebuggerReplicator::OnDebugAIDelegate(class UCanvas* Canvas, class APlayerController* PC) { #if WITH_EDITOR && ENABLED_GAMEPLAY_DEBUGGER if (!GIsEditor) { return; } if (!LocalPlayerOwner) { return; } UEditorEngine* EEngine = Cast<UEditorEngine>(GEngine); if (!EEngine || !EEngine->bIsSimulatingInEditor) { return; } if (!Canvas || !Canvas->SceneView || Canvas->SceneView->bIsGameView == false) { return; } FEngineShowFlags EngineShowFlags = Canvas && Canvas->SceneView && Canvas->SceneView->Family ? Canvas->SceneView->Family->EngineShowFlags : FEngineShowFlags(GIsEditor ? EShowFlagInitMode::ESFIM_Editor : EShowFlagInitMode::ESFIM_Game); if (!EngineShowFlags.DebugAI) { return; } EnableDraw(true); UWorld* World = GetWorld(); if (World && Role == ROLE_Authority) { if (IsActorTickEnabled() == false) { SetActorTickEnabled(true); } // looks like Simulate in UE4 Editor - let's find selected Pawn to debug AActor* SelectedActor = nullptr; for (FSelectionIterator It = EEngine->GetSelectedActorIterator(); It; ++It) { SelectedActor = Cast<APawn>(*It); //we only work with pawns for now if (SelectedActor) { break; } } if (LastSelectedActorToDebug != SelectedActor) { MarkComponentsRenderStateDirty(); } ServerSetActorToDebug(SelectedActor); DrawDebugData(Canvas, PC, true); } #endif }
void ARoadFeverCameraSystem::OnActorLeave( class AActor* InOtherActor, class UPrimitiveComponent* InOtherComp, int32 InOtherBodyIndex ) { // If it is the player's camera dummy. [11/12/2015 Matthew Woolley] if ( InOtherActor->IsA( ARoadFeverCameraDummy::StaticClass() ) ) { ARoadFeverCharacterNed* PlayerCharacter = Cast<ARoadFeverCharacterNed>( GetWorld()->GetFirstPlayerController()->GetPawn() ); if ( PlayerCharacter->CurrentCamera == this ) { if ( RevertTo != nullptr ) { PlayerCharacter->CurrentCamera = RevertTo; // Set the camera's position. [11/12/2015 Matthew Woolley] PlayerCharacter->CharactersCamera->SetWorldLocation( RevertTo->CameraPosition.Location ); PlayerCharacter->CharactersCamera->SetWorldRotation( RevertTo->CameraPosition.Rotation ); } else { PlayerCharacter->CurrentCamera = nullptr; } } if ( RevertTo == this ) { RevertTo = nullptr; } SetActorTickEnabled( false ); } }
void AGameplayDebuggerReplicator::ClientActivateGameplayDebugger_Implementation(bool bActivate) { #if ENABLED_GAMEPLAY_DEBUGGER SetActorTickEnabled(bActivate); MarkComponentsRenderStateDirty(); #endif }
AAURMarkerBoardDefinitionBase::AAURMarkerBoardDefinitionBase() : SavedFileDir("AugmentedUnreality/Markers") , DictionaryId(cv::aruco::DICT_4X4_100) //, AutomaticMarkerIds(true) { PrimaryActorTick.bStartWithTickEnabled = false; SetActorTickEnabled(false); }
AKUIPlayerController::AKUIPlayerController( const class FObjectInitializer& oObjectInitializer ) : Super( oObjectInitializer ) { bHasPlayEnded = false; PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bTickEvenWhenPaused = true; SetActorTickEnabled( true ); }
void AGameplayDebuggerReplicator::ServerActivateGameplayDebugger_Implementation(bool bActivate) { #if ENABLED_GAMEPLAY_DEBUGGER bReplicates = !bActivate; SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy); SetReplicates(bActivate); SetActorTickEnabled(bActivate); #endif }
void AFunctionalTest::FinishTest(TEnumAsByte<EFunctionalTestResult::Type> TestResult, const FString& Message) { const static UEnum* FTestResultTypeEnum = FindObject<UEnum>( NULL, TEXT("FunctionalTesting.FunctionalTest.EFunctionalTestResult") ); bIsRunning = false; SetActorTickEnabled(false); OnTestFinished.Broadcast(); AActor** ActorToDestroy = AutoDestroyActors.GetTypedData(); for (int32 ActorIndex = 0; ActorIndex < AutoDestroyActors.Num(); ++ActorIndex, ++ActorToDestroy) { if (*ActorToDestroy != NULL) { // will be removed next frame (*ActorToDestroy)->SetLifeSpan( 0.01f ); } } const FText ResultText = FTestResultTypeEnum->GetEnumText( TestResult.GetValue() ); const FString OutMessage = FString::Printf(TEXT("%s> Result: %s> %s") , *GetActorLabel() , *ResultText.ToString() , Message.IsEmpty() == false ? *Message : TEXT("Test finished") ); AutoDestroyActors.Reset(); EMessageSeverity::Type MessageLogSeverity = EMessageSeverity::Info; switch (TestResult.GetValue()) { case EFunctionalTestResult::Invalid: case EFunctionalTestResult::Error: UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage); MessageLogSeverity = EMessageSeverity::Error; break; case EFunctionalTestResult::Running: UE_VLOG(this, LogFunctionalTest, Warning, TEXT("%s"), *OutMessage); MessageLogSeverity = EMessageSeverity::Warning; break; case EFunctionalTestResult::Failed: UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage); MessageLogSeverity = EMessageSeverity::Error; break; default: UE_VLOG(this, LogFunctionalTest, Log, TEXT("%s"), *OutMessage); break; } FMessageLog("FunctionalTestingLog").Message(MessageLogSeverity, FText::FromString(GetActorLabel())) ->AddToken( FTextToken::Create( ResultText ) ) ->AddToken( FTextToken::Create( Message.IsEmpty() == false ? FText::FromString(Message) : NSLOCTEXT("FunctionalTest", "FinishedTest", "Test finished") ) ); TestFinishedObserver.ExecuteIfBound(this); }
ALivingBomb::ALivingBomb(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer), Damage(10.0f), ExplosionDamage(90.0f), BombDuration(10.0f), ExplosionSize(5.0f), Enlargened(false), bShouldDestroy(false) { BombBody = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("BombBody")); RootComponent = BombBody; PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); }
AAirCurrent::AAirCurrent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer), LaunchSpeed(300.0f), Duration(0.0f), Caster(nullptr) { CollisionComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("FireWallCollisionComp")); //can't change name, wierd bug RootComponent = CollisionComp; //Allow the actor to tick anywhere PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); }
void AFunctionalTest::StartTest() { if (TimeLimit > 0) { TimeLeft = TimeLimit; SetActorTickEnabled(true); } bIsRunning = true; OnTestStart.Broadcast(); }
void AXHackTrigger::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); for (int32 i = 0; i < Users.Num(); i++) { if (!Users[i].bUsing) continue; AXCharacter* XCharacter = Cast<AXCharacter>(Users[i].UserController->GetPawn()); UXCharacterMovement* XCharacterMovement = Cast<UXCharacterMovement>(XCharacter->GetCharacterMovement()); int32 UserTeam = XCharacter->GetTeamNum(); if (UserTeam != TeamNum) { float NeededSkill = XCharacter->HackCost * XCharacter->HackRate * DeltaSeconds; if (XCharacterMovement->HasNeededSkill(NeededSkill)) { float Hackage = XCharacter->HackRate * DeltaSeconds; TeamProgress[UserTeam] += Hackage; Users[i].ProgressValue += Hackage; XCharacterMovement->UseSkill(NeededSkill); } } } if (Users.Num()>0) { for (int32 i = 0; i < ARRAY_COUNT(TeamProgress); i++) { if (TeamProgress[i]>TotalHackSeconds) { HandleHacked(i); } } } DecayHackProcess(DeltaSeconds); RemoveIdleUsers(); if (UserCount(0, true) + UserCount(1, true) == 0) { CurrentAmbientSound = NULL; AmbientSoundUpdated(); } if (!ProgressExists()) { SetActorTickEnabled(false); } }
bool AFunctionalTest::StartTest(const TArray<FString>& Params) { FailureMessage = TEXT(""); TotalTime = 0.f; if (TimeLimit > 0) { SetActorTickEnabled(true); } bIsRunning = true; GoToObservationPoint(); OnTestStart.Broadcast(); return true; }
void AGameplayDebuggerReplicator::OnActivationKeyPressed() { #if ENABLED_GAMEPLAY_DEBUGGER const bool bIsActive = IsActorTickEnabled(); bEnabledTargetSelection = true; if (DebugCameraController.IsValid()) { return; } ActivationKeyTime = 0; bActivationKeyPressed = true; if (!bIsActive) { SetActorTickEnabled(true); } #endif }
void AXHackTrigger::OnUse(AXPlayerController* User) { //ServerOnUse(User); if (AllowedToHack(User) && bHackable) { AddUser(User); CurrentAmbientSound = HackAmbientSound; SetActorTickEnabled(true); AmbientSoundUpdated(); UUTGameplayStatics::UTPlaySound(GetWorld(), StartHackSound, this, SRT_None); } else { UUTGameplayStatics::UTPlaySound(GetWorld(), DeniedSound, this, SRT_None); } }
void ATDCAIController::UnPossess() { /* if (GetPawn()) { const APawn* TargetPawn = Cast<APawn>(CurrentTarget); if (TargetPawn != NULL) { AStrategyAIController* const AITarget = Cast<AStrategyAIController>(TargetPawn->Controller); if (AITarget != NULL) { AITarget->UnClaimAsTarget(this); } } }*/ SetActorTickEnabled(false); Super::UnPossess(); }
AParticleList::AParticleList(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { // Use a sphere as a simple collision representation CollisionComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("BoxComp")); // Players can't walk on it CollisionComp->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f)); CollisionComp->CanCharacterStepUpOn = ECB_No; // Set as root component RootComponent = CollisionComp; //Allow the actor to tick anywhere PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); }
ACyclone::ACyclone(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer), MaxSwerveSpeed(300.0f), MinSwerveSpeed(100.0f), MaxSwerveDuration(1.0f), MinSwerveDuration(0.2f), RandomizeSwerve(true), CurrentSwerveDuration(0.0f), CurrentSwerveSpeed(0.0f), FirstSwerve(true) { CollisionComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("CycloneCollisionComp")); RootComponent = CollisionComp; //CollisionComp->OnComponentHit.AddDynamic(this, &ACyclone::OnHit); //CollisionComp->OnComponentBeginOverlap.AddDynamic(this, &ACyclone::OnOverlapBegin); // seem no use // Use a ProjectileMovementComponent to govern this projectile's movement ProjectileMovement = ObjectInitializer.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("CycloneProjectileComp")); ProjectileMovement->UpdatedComponent = CollisionComp; //Allow the actor to tick anywhere PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); }
AWindShaman::AWindShaman(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer), bCanHover(false), CurrentGrenade(nullptr), HoverDuration(2.0f), CurrentHoverDuration(0.0f), IsHovering(false), VelocityLastFrame(0.0f), FallingLastFrame(false), BaseAttackDelay(0.1f), MaxAttackDelay(1.0f), AttackFalloffPerSecond(0.1), RechargeMultiplier(2.0f), MaxAirCurrents(3), Currents(), ShotsPerBurst(3), ShotsTaken(0) { AddAbility(new AirCurrentAbility(this)); AddAbility(new CycloneAbility(this)); AddAbility(new VortexGrenadeAbility(this)); BaseAirMovement = GetCharacterMovement()->AirControl; BaseGravityScale = GetCharacterMovement()->GravityScale; PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); CanRapidFire = true; UpperState = EWindUpperState::NoAction; TotalSonicBoltDelay = 0.1f; CurrentSonicBoltDelay = -1.0f; TotalCycloneDelay = 0.1f; CurrentCycloneDelay = -1.0f; TotalAirCurrentDelay = 0.1f; CurrentAirCurrentDelay = -1.0f; TotalVortexGrenadeDelay = 0.1f; CurrentVortexGrenadeDelay = -1.0f; TotalPostSonicBoltDelay = 0.2f; CurrentPostSonicBoltDelay = -1.0f; TotalPostCycloneDelay = 0.2f; CurrentPostCycloneDelay = -1.0f; TotalPostVortexGrenadeDelay = 0.2f; CurrentPostVortexGrenadeDelay = -1.0f; TotalDetonateDelay = 2.0f; CurrentDetonateDelay = -1.0f; WindMoveState = EWindMoveState::NoSpecialMove; bIsLeftButtonDown = false; bIsRightButtonDown = false; WindDetonateState = EWindDetonateState::NoGrenade; }
AKUIInterface::AKUIInterface( const class FObjectInitializer& oObjectInitializer ) : Super(oObjectInitializer) { KUI_UO_INIT_DEBUG() PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bTickEvenWhenPaused = true; SetActorTickEnabled( true ); bVisible = true; bCursorVisible = true; v2ScreenResolution = FVector2D::ZeroVector; v2CursorLocation = FVector2D( KUI_INTERFACE_FIRST_CURSOR_UPDATE, 0.f ); v2CursorVector = FVector2D::ZeroVector; arCancellables.SetNum( 0 ); ctFocused = NULL; ctRootContainers.SetNum( 4 ); KUICreateDefaultSubobjectAssign( ctRootContainers[ EKUIInterfaceRoot::R_Root ], UKUIRootContainer, "Root Container" ); ctRootContainers[ EKUIInterfaceRoot::R_Root ]->SetInterface( this ); KUICreateDefaultSubobjectAssign( ctRootContainers[ EKUIInterfaceRoot::R_Overlay ], UKUIRootContainer, "Overlay Container" ); ctRootContainers[ EKUIInterfaceRoot::R_Overlay ]->SetInterface( this ); KUICreateDefaultSubobjectAssign( ctRootContainers[ EKUIInterfaceRoot::R_Tooltip ], UKUITooltipContainer, "Tooltip Container" ); ctRootContainers[ EKUIInterfaceRoot::R_Tooltip ]->SetInterface( this ); KUICreateDefaultSubobjectAssign( ctRootContainers[ EKUIInterfaceRoot::R_Cursor ], UKUICursorContainer, "Cursor Container" ); ctRootContainers[ EKUIInterfaceRoot::R_Cursor ]->SetInterface( this ); arMouseButtonDownLocations.SetNum( 3 ); arMouseButtonDownLocations[ EMouseButtons::Left ] = FVector2D::ZeroVector; arMouseButtonDownLocations[ EMouseButtons::Right ] = FVector2D::ZeroVector; arMouseButtonDownLocations[ EMouseButtons::Middle ] = FVector2D::ZeroVector; if ( !IsTemplate() ) aLatestInstance = this; }
// Called at the beginning of game-play. [11/12/2015 Matthew Woolley] void ARoadFeverCameraSystem::BeginPlay() { Super::BeginPlay(); // Get the camera's position. [11/12/2015 Matthew Woolley] CameraPosition.Location = EditorCameraReference->GetComponentLocation(); CameraPosition.Rotation = EditorCameraReference->GetComponentRotation(); // Destroy the camera so that the game doesn't keep rendering un-needed scenes. [11/12/2015 Matthew Woolley] EditorCameraReference->DestroyComponent(); if ( bIsPrimaryCamera ) { ARoadFeverCharacterNed* PlayerCharacter = Cast<ARoadFeverCharacterNed>( GetWorld()->GetFirstPlayerController()->GetPawn() ); OnActorEnter( PlayerCharacter->GetCameraDummy(), nullptr, 0, false, FHitResult() ); // Set the camera's position. [11/12/2015 Matthew Woolley] PlayerCharacter->CharactersCamera->SetWorldLocation( CameraPosition.Location ); PlayerCharacter->CharactersCamera->SetWorldRotation( CameraPosition.Rotation ); } else { SetActorTickEnabled( false ); } }
void AGameplayDebuggerPlayerManager::BeginPlay() { Super::BeginPlay(); UWorld* World = GetWorld(); const ENetMode NetMode = World->GetNetMode(); bHasAuthority = (NetMode != NM_Client); bIsLocal = (NetMode != NM_DedicatedServer); bInitialized = true; if (bHasAuthority) { UpdateAuthReplicators(); SetActorTickEnabled(true); } for (int32 Idx = 0; Idx < PendingRegistrations.Num(); Idx++) { RegisterReplicator(*PendingRegistrations[Idx]); } PendingRegistrations.Empty(); }
void AMWMot::OnKaput() { // Enable physics for the mesh Mesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block); Mesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_Vehicle, ECollisionResponse::ECR_Ignore); // Vehicle = root capsule component of Pat Mesh->SetSimulatePhysics(true); // Turn off the lightcone Lightcone->SetVisibility(false, true); // Disable ticking the actor SetActorTickEnabled(false); // Stop the behavior tree AAIController* controller = Cast<AAIController>(GetController()); if (controller) { UBehaviorTreeComponent* behavior = Cast<UBehaviorTreeComponent>(controller->BrainComponent); if (behavior) { behavior->StopTree(); } } }
AGameplayDebuggingReplicator::AGameplayDebuggingReplicator(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) , MaxEQSQueries(5) , bIsGlobalInWorld(true) , LastDrawAtFrame(0) , PlayerControllersUpdateDelay(0) { #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) // Structure to hold one-time initialization struct FConstructorStatics { ConstructorHelpers::FObjectFinderOptional<UTexture2D> RedIcon; ConstructorHelpers::FObjectFinderOptional<UTexture2D> GreenIcon; // both icons are needed to debug AI FConstructorStatics() : RedIcon(TEXT("/Engine/EngineResources/AICON-Red.AICON-Red")) , GreenIcon(TEXT("/Engine/EngineResources/AICON-Green.AICON-Green")) { } }; static FConstructorStatics ConstructorStatics; DefaultTexture_Red = ConstructorStatics.RedIcon.Get(); DefaultTexture_Green = ConstructorStatics.GreenIcon.Get(); PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = false; USceneComponent* SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComponent")); RootComponent = SceneComponent; #if WITH_EDITOR SetIsTemporarilyHiddenInEditor(true); #endif #if WITH_EDITORONLY_DATA SetTickableWhenPaused(true); SetActorHiddenInGame(false); bHiddenEdLevel = true; bHiddenEdLayer = true; bHiddenEd = true; bEditable = false; #endif DebuggerShowFlags = GameplayDebuggerSettings().DebuggerShowFlags; FGameplayDebuggerSettings Settings = GameplayDebuggerSettings(this); #define UPDATE_VIEW_PROPS(__FlagName__) __FlagName__ = Settings.CheckFlag(EAIDebugDrawDataView::__FlagName__); UPDATE_VIEW_PROPS(OverHead); UPDATE_VIEW_PROPS(Basic); UPDATE_VIEW_PROPS(BehaviorTree); UPDATE_VIEW_PROPS(EQS); UPDATE_VIEW_PROPS(Perception); UPDATE_VIEW_PROPS(GameView1); UPDATE_VIEW_PROPS(GameView2); UPDATE_VIEW_PROPS(GameView3); UPDATE_VIEW_PROPS(GameView4); UPDATE_VIEW_PROPS(GameView5); #undef UPDATE_VIEW_PROPS EnableEQSOnHUD = true; if (!HasAnyFlags(RF_ClassDefaultObject)) { SetActorTickEnabled(true); bReplicates = false; SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy); SetReplicates(true); AGameplayDebuggingReplicator::OnSelectionChangedDelegate.AddUObject(this, &AGameplayDebuggingReplicator::ServerSetActorToDebug); } #endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST) }
ATotemCharacter::ATotemCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer), BaseTurnRate(45.0f), BaseLookUpRate(45.0f), PlayerHealth(100.0f), ProjectileDamage(10.0f), TimeBetweenShots(0.5f), ShotPressed(false), ShotFired(false), TimeSinceAttack(0.0f), CanRapidFire(false), MoveSpeedScale(1.0f), StrafeSpeedScale(1.0f), PreviousHit(), bInvincible(false), CurrentAbility(nullptr), bCanMove(true), AttachCyclone(nullptr), NumAbilities(0), bFirstSpawn(true), bBeingKnockedBack(false), TimeRestoreFromKnockedBack(3.0f), TimeSinceKnockedBack(-1.0f), DamageScale(1.0f), bAcceptMoveInput(true), DistanceFromPlayer(0.0f), FirstTick(true), ThirdPersonAbilityCamDistance(550.0f), ThirdPersonDeathCamDistance(700.0f), bClickedThisFrame(false), bDeathCam(false), bDeathEffectFired(false), DeathCamAngle(20), InstigKillTimer(5.0f), TimeSinceHit(0.0f) { Instigator = this; //seem instigator automagically be himself, but for safe, I assign again // Set size for collision capsule GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f); //Create CameraBoom for Third person Camera CameraBoom = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom")); CameraBoom->AttachParent = GetCapsuleComponent(); CameraBoom->RelativeLocation = FVector(0, 0, 64.f); // Position the camera CameraBoom->TargetArmLength = 0; CameraBoom->bUsePawnControlRotation = true; // Create a CameraComponent FirstPersonCameraComponent = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FirstPersonCamera")); //FirstPersonCameraComponent->AttachParent = GetCapsuleComponent(); FirstPersonCameraComponent->AttachParent = CameraBoom; FirstPersonCameraComponent->RelativeLocation = FVector(20, 0, 0); // Position the camera FirstPersonCameraComponent->bUsePawnControlRotation = true; // Create a CameraComponent PlayerBody = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PlayerBody")); PlayerBody->AttachParent = GetCapsuleComponent(); PlayerBody->RelativeLocation = FVector(0, 0, 0); // Position the body // Default offset from the character location for projectiles to spawn GunOffset = FVector(100.0f, 30.0f, 10.0f); // Create a mesh component that will be used when being viewed from a '1st person' view (when controlling this pawn) Mesh1P = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("CharacterMesh1P")); Mesh1P->SetOnlyOwnerSee(true); // only the owning player will see this mesh Mesh1P->AttachParent = FirstPersonCameraComponent; Mesh1P->RelativeLocation = FVector(0.f, 0.f, -150.f); Mesh1P->bCastDynamicShadow = false; Mesh1P->CastShadow = false; //bReplicates = true; // Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P are set in the // derived blueprint asset named MyCharacter (to avoid direct content references in C++) //Allow the actor to ( anywhere PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bStartWithTickEnabled = true; PrimaryActorTick.bAllowTickOnDedicatedServer = true; SetActorTickEnabled(true); Metrics::CreateInstance(); //Death state bIsDead = false; TotalDeadBodyDuration = 5.0f; CurrentDeadBodyDuration = -1.0f; Team = ETeam::NO_TEAM; bCanBasicAttack = false; bCanUseAbility = false; bAcceptMoveInput = false; bReborn = true; TotalRebornDuration = 0.1f; bAcceptCameraChange = true; bThirdPersonCamLerp = false; bThirdPersonDeathCamLerp = false; bRightButtonDownThisFrame = false; TotemCharacterMoveState = ETotemCharacterMoveState::NoMove; NormalWalkSpeed = 600.0f; //Just a random number SprintSpeed = 1200.0f; DeathDissolvePlayAfterTimer = 0.733f; }
void AFunctionalTest::FinishTest(TEnumAsByte<EFunctionalTestResult::Type> TestResult, const FString& Message) { const static UEnum* FTestResultTypeEnum = FindObject<UEnum>( NULL, TEXT("FunctionalTesting.FunctionalTest.EFunctionalTestResult") ); if (bIsRunning == false) { // ignore return; } Result = TestResult; bIsRunning = false; SetActorTickEnabled(false); OnTestFinished.Broadcast(); AActor** ActorToDestroy = AutoDestroyActors.GetData(); for (int32 ActorIndex = 0; ActorIndex < AutoDestroyActors.Num(); ++ActorIndex, ++ActorToDestroy) { if (*ActorToDestroy != NULL) { // will be removed next frame (*ActorToDestroy)->SetLifeSpan( 0.01f ); } } const FText ResultText = FTestResultTypeEnum->GetEnumText( TestResult.GetValue() ); const FString OutMessage = FString::Printf(TEXT("%s %s: \"%s\'") , *GetActorLabel() , *ResultText.ToString() , Message.IsEmpty() == false ? *Message : TEXT("Test finished") ); const FString AdditionalDetails = GetAdditionalTestFinishedMessage(TestResult) + FString::Printf(TEXT(", time %.2fs"), TotalTime); AutoDestroyActors.Reset(); switch (TestResult.GetValue()) { case EFunctionalTestResult::Invalid: case EFunctionalTestResult::Error: case EFunctionalTestResult::Failed: UE_VLOG(this, LogFunctionalTest, Error, TEXT("%s"), *OutMessage); UFunctionalTestingManager::AddError(FText::FromString(OutMessage)); break; case EFunctionalTestResult::Running: UE_VLOG(this, LogFunctionalTest, Warning, TEXT("%s"), *OutMessage); UFunctionalTestingManager::AddWarning(FText::FromString(OutMessage)); break; default: UE_VLOG(this, LogFunctionalTest, Log, TEXT("%s"), *OutMessage); UFunctionalTestingManager::AddLogItem(FText::FromString(OutMessage)); break; } if (AdditionalDetails.IsEmpty() == false) { UFunctionalTestingManager::AddLogItem(FText::FromString(AdditionalDetails)); } TestFinishedObserver.ExecuteIfBound(this); }
bool AFunctionalAITest::StartTest(const TArray<FString>& Params) { KillOffSpawnedPawns(); ClearPendingDelayedSpawns(); bSingleSetRun = Params.Num() > 0; if (bSingleSetRun) { TTypeFromString<int32>::FromString(CurrentSpawnSetIndex, *Params[0]); } else { ++CurrentSpawnSetIndex; } if (CurrentSpawnSetIndex < SpawnSets.Num()) { UWorld* World = GetWorld(); check(World); const FAITestSpawnSet& SpawnSet = SpawnSets[CurrentSpawnSetIndex]; bool bSuccessfullySpawnedAll = true; // NOTE: even if some pawns fail to spawn we don't stop spawning to find all spawns that will fails. // all spawned pawns get filled off in case of failure. CurrentSpawnSetName = SpawnSet.Name.ToString(); for (int32 SpawnIndex = 0; SpawnIndex < SpawnSet.SpawnInfoContainer.Num(); ++SpawnIndex) { const FAITestSpawnInfo& SpawnInfo = SpawnSet.SpawnInfoContainer[SpawnIndex]; if (SpawnInfo.IsValid()) { if (SpawnInfo.SpawnDelay == 0.0) { for (int32 SpawnedCount = 0; SpawnedCount < SpawnInfo.NumberToSpawn; ++SpawnedCount) { bSuccessfullySpawnedAll &= SpawnInfo.Spawn(this); } } else { bSuccessfullySpawnedAll &= SpawnInfo.Spawn(this); if (SpawnInfo.NumberToSpawn > 1) { PendingDelayedSpawns.Add(SpawnInfo); } } } else { FString FailureMessage = FString::Printf(TEXT("Spawn set \'%s\' contains invalid entry at index %d") , *SpawnSet.Name.ToString() , SpawnIndex); UE_LOG(LogFunctionalTest, Warning, TEXT("%s"), *FailureMessage); bSuccessfullySpawnedAll = false; } } if (bSuccessfullySpawnedAll == false) { KillOffSpawnedPawns(); } else { if (PendingDelayedSpawns.Num() > 0) { SetActorTickEnabled(true); } return Super::StartTest(); } } return false; }
void AFunctionalAITest::ClearPendingDelayedSpawns() { SetActorTickEnabled(false); PendingDelayedSpawns.Reset(); }
AMech_RPGCharacter::AMech_RPGCharacter() : healthChangeModifier(1), inventory(NewObject<UInventory>(UInventory::StaticClass())), defenceModifier(0), speedModifier(1), startingRole(GroupEnums::DPS), health(2000), maxHealth(2000), channeling(false), team(TeamEnums::Paladins) { static int32 ID = 0; SetID(ID++); SetActorTickEnabled(true); AIControllerClass = ABaseAIController::StaticClass(); // Create a camera boom... CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom")); CameraBoom->AttachToComponent(RootComponent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); CameraBoom->bAbsoluteRotation = true; // Don't want arm to rotate when character does CameraBoom->TargetArmLength = 1800.0f; CameraBoom->RelativeRotation = FRotator(-85.f, 0.f, 0.f); CameraBoom->bDoCollisionTest = false; // Don't want to pull camera in when it collides with level // Create a camera... TopDownCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopDownCamera")); TopDownCameraComponent->AttachToComponent(CameraBoom, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false), USpringArmComponent::SocketName); TopDownCameraComponent->bUsePawnControlRotation = false; // Camera does not rotate relative to arm // Don't rotate character to camera direction bUseControllerRotationPitch = false; bUseControllerRotationYaw = false; bUseControllerRotationRoll = false; // Configure character movement GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f); GetCharacterMovement()->bConstrainToPlane = true; GetCharacterMovement()->bSnapToPlaneAtStart = true; GetCharacterMovement()->bCanWalkOffLedges = false; GetCharacterMovement()->SetWalkableFloorAngle(90); GetCharacterMovement()->SetAvoidanceGroup(0); GetCharacterMovement()->SetGroupsToAvoid(0); //GetCharacterMovement()->SetGroupsToIgnore(0); speed = GetCharacterMovement()->MaxWalkSpeed; static ConstructorHelpers::FClassFinder<UFloatingStats_BP> statsWidget(TEXT("/Game/TopDown/Blueprints/UI/CharacterUI/FloatingStats")); if (statsWidget.Succeeded()) { widgetClass = statsWidget.Class; stats = CreateDefaultSubobject<UWidgetComponent>(TEXT("Floating Stats Component")); stats->AttachToComponent(GetRootComponent(), FAttachmentTransformRules(EAttachmentRule::KeepRelative, false)); } static ConstructorHelpers::FClassFinder<UFloatingTextUI> floatingTextWidget(TEXT("/Game/TopDown/Blueprints/UI/CharacterUI/Floating_Text")); if (floatingTextWidget.Succeeded()) { floatingTextClass = floatingTextWidget.Class; } static ConstructorHelpers::FObjectFinder<USkeletalMesh> newMesh(TEXT("/Game/TopDown/Meshes/Mech/Mech.Mech")); if (newMesh.Succeeded()) { GetMesh()->SetSkeletalMesh(newMesh.Object); GetMesh()->SetCollisionEnabled(ECollisionEnabled::QueryOnly); GetMesh()->SetCollisionObjectType(mCharacterCollision); } // Set size for player capsule GetCapsuleComponent()->InitCapsuleSize(60.0f, 140.0f); GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::QueryOnly); GetCapsuleComponent()->SetCollisionObjectType(mCharacterCollision); GetCapsuleComponent()->SetCollisionResponseToChannel(mItemCollision, ECollisionResponse::ECR_Ignore); //GetCapsuleComponent()->SetCollisionResponseToChannel(mCharacterCollision, ECollisionResponse::ECR_Ignore); //radiusDection = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent")); //radiusDection->InitSphereRadius(1500.0f); //radiusDection->SetCollisionProfileName(TEXT("Pawn")); //radiusDection->AttachTo(this->RootComponent); //radiusDection->SetCollisionEnabled(ECollisionEnabled::QueryOnly); characters.Add(this); }
void ATDCAIController::Possess(class APawn* inPawn) { Super::Possess(inPawn); SetActorTickEnabled(true); }