Added the Unreal Project to the repo
Adding a Third Person Unreal Template project to the repo
This commit is contained in:
15
Source/jumpingship.Target.cs
Normal file
15
Source/jumpingship.Target.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class jumpingshipTarget : TargetRules
|
||||
{
|
||||
public jumpingshipTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V4;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_3;
|
||||
ExtraModuleNames.Add("jumpingship");
|
||||
}
|
||||
}
|
27
Source/jumpingship/MyActor.cpp
Normal file
27
Source/jumpingship/MyActor.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MyActor.h"
|
||||
|
||||
// Sets default values
|
||||
AMyActor::AMyActor()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AMyActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AMyActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
26
Source/jumpingship/MyActor.h
Normal file
26
Source/jumpingship/MyActor.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "MyActor.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class JUMPINGSHIP_API AMyActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AMyActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
};
|
13
Source/jumpingship/jumpingship.Build.cs
Normal file
13
Source/jumpingship/jumpingship.Build.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class jumpingship : ModuleRules
|
||||
{
|
||||
public jumpingship(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
|
||||
}
|
||||
}
|
7
Source/jumpingship/jumpingship.cpp
Normal file
7
Source/jumpingship/jumpingship.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "jumpingship.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, jumpingship, "jumpingship" );
|
||||
|
5
Source/jumpingship/jumpingship.h
Normal file
5
Source/jumpingship/jumpingship.h
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
130
Source/jumpingship/jumpingshipCharacter.cpp
Normal file
130
Source/jumpingship/jumpingshipCharacter.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "jumpingshipCharacter.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "GameFramework/Controller.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "InputActionValue.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogTemplateCharacter);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AjumpingshipCharacter
|
||||
|
||||
AjumpingshipCharacter::AjumpingshipCharacter()
|
||||
{
|
||||
// Set size for collision capsule
|
||||
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
|
||||
|
||||
// Don't rotate when the controller rotates. Let that just affect the camera.
|
||||
bUseControllerRotationPitch = false;
|
||||
bUseControllerRotationYaw = false;
|
||||
bUseControllerRotationRoll = false;
|
||||
|
||||
// Configure character movement
|
||||
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
|
||||
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
|
||||
|
||||
// Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
|
||||
// instead of recompiling to adjust them
|
||||
GetCharacterMovement()->JumpZVelocity = 700.f;
|
||||
GetCharacterMovement()->AirControl = 0.35f;
|
||||
GetCharacterMovement()->MaxWalkSpeed = 500.f;
|
||||
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
|
||||
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
|
||||
GetCharacterMovement()->BrakingDecelerationFalling = 1500.0f;
|
||||
|
||||
// Create a camera boom (pulls in towards the player if there is a collision)
|
||||
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
|
||||
CameraBoom->SetupAttachment(RootComponent);
|
||||
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
|
||||
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
|
||||
|
||||
// Create a follow camera
|
||||
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
|
||||
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
|
||||
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
|
||||
|
||||
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
|
||||
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
|
||||
}
|
||||
|
||||
void AjumpingshipCharacter::BeginPlay()
|
||||
{
|
||||
// Call the base class
|
||||
Super::BeginPlay();
|
||||
|
||||
//Add Input Mapping Context
|
||||
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
|
||||
{
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
|
||||
{
|
||||
Subsystem->AddMappingContext(DefaultMappingContext, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Input
|
||||
|
||||
void AjumpingshipCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
// Set up action bindings
|
||||
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent)) {
|
||||
|
||||
// Jumping
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
|
||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
|
||||
|
||||
// Moving
|
||||
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AjumpingshipCharacter::Move);
|
||||
|
||||
// Looking
|
||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AjumpingshipCharacter::Look);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this));
|
||||
}
|
||||
}
|
||||
|
||||
void AjumpingshipCharacter::Move(const FInputActionValue& Value)
|
||||
{
|
||||
// input is a Vector2D
|
||||
FVector2D MovementVector = Value.Get<FVector2D>();
|
||||
|
||||
if (Controller != nullptr)
|
||||
{
|
||||
// find out which way is forward
|
||||
const FRotator Rotation = Controller->GetControlRotation();
|
||||
const FRotator YawRotation(0, Rotation.Yaw, 0);
|
||||
|
||||
// get forward vector
|
||||
const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
|
||||
|
||||
// get right vector
|
||||
const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
|
||||
|
||||
// add movement
|
||||
AddMovementInput(ForwardDirection, MovementVector.Y);
|
||||
AddMovementInput(RightDirection, MovementVector.X);
|
||||
}
|
||||
}
|
||||
|
||||
void AjumpingshipCharacter::Look(const FInputActionValue& Value)
|
||||
{
|
||||
// input is a Vector2D
|
||||
FVector2D LookAxisVector = Value.Get<FVector2D>();
|
||||
|
||||
if (Controller != nullptr)
|
||||
{
|
||||
// add yaw and pitch input to controller
|
||||
AddControllerYawInput(LookAxisVector.X);
|
||||
AddControllerPitchInput(LookAxisVector.Y);
|
||||
}
|
||||
}
|
73
Source/jumpingship/jumpingshipCharacter.h
Normal file
73
Source/jumpingship/jumpingshipCharacter.h
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Logging/LogMacros.h"
|
||||
#include "jumpingshipCharacter.generated.h"
|
||||
|
||||
class USpringArmComponent;
|
||||
class UCameraComponent;
|
||||
class UInputMappingContext;
|
||||
class UInputAction;
|
||||
struct FInputActionValue;
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateCharacter, Log, All);
|
||||
|
||||
UCLASS(config=Game)
|
||||
class AjumpingshipCharacter : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/** Camera boom positioning the camera behind the character */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
||||
USpringArmComponent* CameraBoom;
|
||||
|
||||
/** Follow camera */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
|
||||
UCameraComponent* FollowCamera;
|
||||
|
||||
/** MappingContext */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
UInputMappingContext* DefaultMappingContext;
|
||||
|
||||
/** Jump Input Action */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
UInputAction* JumpAction;
|
||||
|
||||
/** Move Input Action */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
UInputAction* MoveAction;
|
||||
|
||||
/** Look Input Action */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
UInputAction* LookAction;
|
||||
|
||||
public:
|
||||
AjumpingshipCharacter();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** Called for movement input */
|
||||
void Move(const FInputActionValue& Value);
|
||||
|
||||
/** Called for looking input */
|
||||
void Look(const FInputActionValue& Value);
|
||||
|
||||
|
||||
protected:
|
||||
// APawn interface
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
// To add mapping context
|
||||
virtual void BeginPlay();
|
||||
|
||||
public:
|
||||
/** Returns CameraBoom subobject **/
|
||||
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
|
||||
/** Returns FollowCamera subobject **/
|
||||
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
|
||||
};
|
||||
|
15
Source/jumpingship/jumpingshipGameMode.cpp
Normal file
15
Source/jumpingship/jumpingshipGameMode.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "jumpingshipGameMode.h"
|
||||
#include "jumpingshipCharacter.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
|
||||
AjumpingshipGameMode::AjumpingshipGameMode()
|
||||
{
|
||||
// set default pawn class to our Blueprinted character
|
||||
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter"));
|
||||
if (PlayerPawnBPClass.Class != NULL)
|
||||
{
|
||||
DefaultPawnClass = PlayerPawnBPClass.Class;
|
||||
}
|
||||
}
|
19
Source/jumpingship/jumpingshipGameMode.h
Normal file
19
Source/jumpingship/jumpingshipGameMode.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameModeBase.h"
|
||||
#include "jumpingshipGameMode.generated.h"
|
||||
|
||||
UCLASS(minimalapi)
|
||||
class AjumpingshipGameMode : public AGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AjumpingshipGameMode();
|
||||
};
|
||||
|
||||
|
||||
|
15
Source/jumpingshipEditor.Target.cs
Normal file
15
Source/jumpingshipEditor.Target.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class jumpingshipEditorTarget : TargetRules
|
||||
{
|
||||
public jumpingshipEditorTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Editor;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V4;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_3;
|
||||
ExtraModuleNames.Add("jumpingship");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user