-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#include "FPSLaunchPad.h" | ||
#include "Components/StaticMeshComponent.h" | ||
#include "Components/BoxComponent.h" | ||
#include "GameFramework/Character.h" | ||
#include "Kismet/GameplayStatics.h" | ||
|
||
// Sets default values | ||
AFPSLaunchPad::AFPSLaunchPad(): | ||
AppliedStrength(1500.f), | ||
AppliedStrengthAngle(40.f) | ||
{ | ||
OverlapBoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("OverlapBoxComponent")); | ||
OverlapBoxComponent->SetBoxExtent(FVector(60.f, 60.f, 10.f)); | ||
RootComponent = OverlapBoxComponent; | ||
|
||
OverlapBoxComponent->OnComponentBeginOverlap.AddDynamic(this, &AFPSLaunchPad::OverlapLaunchPad); | ||
|
||
MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent")); | ||
MeshComponent->SetupAttachment(OverlapBoxComponent); | ||
} | ||
|
||
void AFPSLaunchPad::OverlapLaunchPad(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, | ||
bool bFromSweep, const FHitResult& SweepResult) | ||
{ | ||
FRotator Direction = GetActorRotation(); | ||
Direction.Add(AppliedStrengthAngle, 0.f, 0.f); | ||
FVector Velocity = Direction.Vector() * AppliedStrength; | ||
|
||
ACharacter* Character = Cast<ACharacter>(OtherActor); | ||
if (Character) | ||
{ | ||
// Apply a force to a player | ||
Character->LaunchCharacter(Velocity, true, true); | ||
|
||
// And spawn some particle effect on the place where we step in | ||
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ParticleSystemEffect, GetActorLocation()); | ||
} | ||
else if (OtherComp && OtherComp->IsSimulatingPhysics()) | ||
{ | ||
// Apply a force to an object | ||
OtherComp->AddImpulse(Velocity, NAME_None, true); | ||
|
||
// And spawn some particle effect on the place where we step in | ||
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ParticleSystemEffect, GetActorLocation()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "GameFramework/Actor.h" | ||
#include "FPSLaunchPad.generated.h" | ||
|
||
class UStaticMeshComponent; | ||
class UBoxComponent; | ||
class UParticleSystem; | ||
|
||
UCLASS() | ||
class FPSGAME_API AFPSLaunchPad : public AActor | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
// Sets default values for this actor's properties | ||
AFPSLaunchPad(); | ||
|
||
protected: | ||
UPROPERTY(VisibleAnywhere, Category = "Components") | ||
UStaticMeshComponent* MeshComponent; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Components") | ||
UBoxComponent* OverlapBoxComponent; | ||
|
||
UPROPERTY(EditDefaultsOnly, Category = "Launchpad Settings") | ||
float AppliedStrength; | ||
|
||
UPROPERTY(EditDefaultsOnly, Category = "Launchpad Settings") | ||
float AppliedStrengthAngle; | ||
|
||
UPROPERTY(EditDefaultsOnly, Category = "Launchpad Settings") | ||
UParticleSystem* ParticleSystemEffect; | ||
|
||
UFUNCTION() | ||
void OverlapLaunchPad(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, | ||
bool bFromSweep, const FHitResult& SweepResult); | ||
}; |