Игра Space Invaders (Galaxian) на Unreal Engine C++/ #9 Передвижение врага, смена направления

  Рет қаралды 37

Narazves gamedev - Unreal Engine C++

Narazves gamedev - Unreal Engine C++

Күн бұрын

Пікірлер: 2
@Narazves_gamedev
@Narazves_gamedev Жыл бұрын
//InvadersEnemy.cpp #include "Components/BrushComponent.h" void AInvadersEnemy::BeginPlay() { Super::BeginPlay(); if (FTimerHandle MoveTimer; !MoveTimer.IsValid()) { GetWorldTimerManager().SetTimer(MoveTimer, this, &ThisClass::Move, 0.05, true); } } void AInvadersEnemy::EnemyOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { if (Cast(OtherActor)) { SpawnExplosionFX(); SpawnSound(); Destroy(); } else if (Cast(OtherComp)) { ChangeDirection(); } } void AInvadersEnemy::Move() { const FVector NewLocation = GetActorLocation() + FVector(0.0, MoveDirection, 0.0); SetActorLocation(NewLocation); } void AInvadersEnemy::ChangeDirection() { TArray OutActors; UGameplayStatics::GetAllActorsOfClass(GetWorld(), StaticClass(), OutActors); for (AActor* EnemyActor : OutActors) { if (AInvadersEnemy* Enemy = Cast(EnemyActor)) { Enemy->MoveDirection *= -1.0; } } }
@Narazves_gamedev
@Narazves_gamedev Жыл бұрын
// InvadersEnemy.h UCLASS() class INVADERS_API AInvadersEnemy : public AActor { GENERATED_BODY() protected: double MoveDirection = -1.0; void Move(); void ChangeDirection(); };
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Здесь упор в процессор
18:02
Рома, Просто Рома
Рет қаралды 880 М.
Предел развития НЕЙРОСЕТЕЙ
18:53
Onigiri
Рет қаралды 167 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН