Skip to content

Commit

Permalink
Implemented Launch pad
Browse files Browse the repository at this point in the history
  • Loading branch information
Relrin committed Jan 2, 2018
1 parent 948f7f1 commit 5101c00
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ SyncSceneSmoothingFactor=0.000000
AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10


Binary file removed Content/Blueprints/BP_BlackHole.uasset
Binary file not shown.
Binary file added Content/Blueprints/Challenges/BP_BlackHole.uasset
Binary file not shown.
Binary file added Content/Blueprints/Challenges/BP_Launchpad.uasset
Binary file not shown.
Binary file added Content/Blueprints/Challenges/TEST.uasset
Binary file not shown.
Binary file modified Content/Maps/FirstPersonExampleMap.umap
Binary file not shown.
Binary file modified Content/Maps/FirstPersonExampleMap_BuiltData.uasset
Binary file not shown.
Binary file added Content/Materials/LaunchPad/M_LaunchPAd.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Materials/LaunchPad/T_Arrow.uasset
Binary file not shown.
49 changes: 49 additions & 0 deletions Source/FPSGame/Private/FPSLaunchPad.cpp
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());
}
}
42 changes: 42 additions & 0 deletions Source/FPSGame/Public/FPSLaunchPad.h
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);
};

0 comments on commit 5101c00

Please sign in to comment.