Launch Pad Challenge: C++/Blueprints
Launch Pad Challenge es el segundo reto propuesto por el curso Unreal Engine 4 Mastery: Create Multiplayer Games with C++ de Tom Looman certificado por Epic Games disponible en la plataforma Udemy.
A lo largo del curso se desarrollarán dos juegos con base en C++ y extendiendo la funcionalidad con Blueprints. Los dos juegos son multijugador y se profundizará también en AI y para reforzar los diferentes temas se proponen distintos retos. En esta ocasión hay que prototipar en BP una plataforma propulsora que impulse tanto al jugador como a elementos del nivel para posteriormente implementarlo en C++.
.h
UPROPERTY(VisibleAnywhere, Category = "Components") UStaticMeshComponent* MeshComp; UPROPERTY(VisibleAnywhere, Category = "Components") UBoxComponent* OverlapComp; // Marked with ufunction to bind to overlap event UFUNCTION() void OverlapLaunchPad(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); /* Total impulse added to the character on overlap Marked 'EditInstanceOnly' to allow in-level editing of this property per instance. */ UPROPERTY(EditInstanceOnly, Category = "LaunchPad") float LaunchStrength; /* Angle added on top of actor rotation to launch the character. Marked 'EditInstanceOnly' to allow in-level editing of this property per instance. */ UPROPERTY(EditInstanceOnly, Category = "LaunchPad") float LaunchPitchAngle; /* Effect to play when activating launch pad */ UPROPERTY(EditDefaultsOnly, Category = "LaunchPad") UParticleSystem* ActivateLaunchPadEffect;
.cpp
// Sets default values
ALaunchPad::ALaunchPad()
{
OverlapComp = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapComp"));
OverlapComp->SetBoxExtent(FVector(75, 75, 50));
RootComponent = OverlapComp;
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
MeshComp->SetupAttachment(RootComponent);
// Bind to Event
OverlapComp->OnComponentBeginOverlap.AddDynamic(this, &ALaunchPad::OverlapLaunchPad);
LaunchStrength = 1500;
LaunchPitchAngle = 35.0f;
}
void ALaunchPad::OverlapLaunchPad(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// Make rotator with our specified 'pitch' and convert to a direction vector * intensity
FRotator LaunchDirection = GetActorRotation();
LaunchDirection.Pitch += LaunchPitchAngle;
FVector LaunchVelocity = LaunchDirection.Vector() * LaunchStrength;
ACharacter* OtherCharacter = Cast<ACharacter>(OtherActor);
if (OtherCharacter)
{
// Launch Player! Both booleans give consistent launch velocity by ignoring the current player velocity
OtherCharacter->LaunchCharacter(LaunchVelocity, true, true);
// Spawn FX
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ActivateLaunchPadEffect, GetActorLocation());
}
// Did not overlap a player, so check if it's a physics simulating actor we can launch
else if (OtherComp && OtherComp->IsSimulatingPhysics())
{
OtherComp->AddImpulse(LaunchVelocity, NAME_None, true);
// Spawn FX
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ActivateLaunchPadEffect, GetActorLocation());
}
}
A continuación os dejaré los enlaces al código, demo y al video en youtube para que podáis ver más. De momento me está gustando el curso pero al final compartiré una valoración general por si a alguien le pueda interesar que sepa más o menos que esperar del mismo.
Repositorio: Launch Pad Challenge: C++/Blueprints [project]
Demo: Launch Pad Challenge: C++/Blueprints [demo]
Curso: Unreal Engine 4 Mastery: Create Multiplayer Games with C++

Lvl 35 | #Porting #GameDev en Catness Game Studios | Ex #AI #GameDev en The Crown of Wu de Red Mountain | Padre de Baby T-Rex.
