1
0

First commit, alpha

This commit is contained in:
2018-01-04 15:44:57 +01:00
parent c43adbdab4
commit 390daa2fa5
148 changed files with 396 additions and 0 deletions

13
Source/Carwatch.Target.cs Normal file
View File

@ -0,0 +1,13 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class CarwatchTarget : TargetRules
{
public CarwatchTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
ExtraModuleNames.Add("Carwatch");
}
}

View File

@ -0,0 +1,13 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class Carwatch : ModuleRules
{
public Carwatch(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
}
}

View File

@ -0,0 +1,7 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Carwatch.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Carwatch, "Carwatch" );

View File

@ -0,0 +1,5 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,63 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CarwatchCharacter.h"
#include "Animation/AnimInstance.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/InputComponent.h"
#include "GameFramework/InputSettings.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Kismet/GameplayStatics.h"
#include "MotionControllerComponent.h"
DEFINE_LOG_CATEGORY_STATIC(LogFPChar, Warning, All);
ACarwatchCharacter::ACarwatchCharacter() {
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
FirstPersonCameraComponent->SetupAttachment(GetCapsuleComponent());
FirstPersonCameraComponent->RelativeLocation = FVector(-40.f, 1.7f, 333.f);
FirstPersonCameraComponent->RelativeRotation = FRotator(-21.5f, 0.f, 0.f);
FirstPersonCameraComponent->bUsePawnControlRotation = true;
}
void ACarwatchCharacter::BeginPlay() {
Super::BeginPlay();
}
void ACarwatchCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) {
check(PlayerInputComponent);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
PlayerInputComponent->BindAxis("MoveForward", this, &ACarwatchCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ACarwatchCharacter::MoveRight);
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("TurnRate", this, &ACarwatchCharacter::TurnAtRate);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("LookUpRate", this, &ACarwatchCharacter::LookUpAtRate);
}
void ACarwatchCharacter::MoveForward(float Value) {
if (Value != 0.0f)
AddMovementInput(GetActorForwardVector(), Value);
}
void ACarwatchCharacter::MoveRight(float Value) {
if (Value != 0.0f) {
AddMovementInput(GetActorRightVector(), Value);
}
}
void ACarwatchCharacter::TurnAtRate(float Rate) {
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}
void ACarwatchCharacter::LookUpAtRate(float Rate) {
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

View File

@ -0,0 +1,39 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "CarwatchCharacter.generated.h"
class UInputComponent;
UCLASS(config=Game)
class ACarwatchCharacter : public ACharacter
{
GENERATED_BODY()
public:
ACarwatchCharacter();
virtual void BeginPlay();
void MoveForward(float Val);
void MoveRight(float Val);
void TurnAtRate(float Rate);
void LookUpAtRate(float Rate);
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FirstPersonCameraComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
float BaseTurnRate;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
float BaseLookUpRate;
};

View File

@ -0,0 +1,10 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CarwatchGameMode.h"
#include "CarwatchHUD.h"
#include "CarwatchCharacter.h"
#include "UObject/ConstructorHelpers.h"
ACarwatchGameMode::ACarwatchGameMode() : Super() {
HUDClass = ACarwatchHUD::StaticClass();
}

View File

@ -0,0 +1,19 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "CarwatchGameMode.generated.h"
UCLASS(minimalapi)
class ACarwatchGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
ACarwatchGameMode();
};

View File

@ -0,0 +1,33 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CarwatchHUD.h"
#include "Engine/Canvas.h"
#include "Engine/Texture2D.h"
#include "TextureResource.h"
#include "CanvasItem.h"
#include "UObject/ConstructorHelpers.h"
ACarwatchHUD::ACarwatchHUD()
{
// Set the crosshair texture
static ConstructorHelpers::FObjectFinder<UTexture2D> CrosshairTexObj(TEXT("Texture2D'/Game/FirstPersonCrosshair.FirstPersonCrosshair'"));
CrosshairTex = CrosshairTexObj.Object;
}
void ACarwatchHUD::DrawHUD()
{
Super::DrawHUD();
// Draw very simple crosshair
// find center of the Canvas
const FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f);
// offset by half the texture's dimensions so that the center of the texture aligns with the center of the Canvas
const FVector2D CrosshairDrawPosition( (Center.X), (Center.Y + 20.0f));
// draw the crosshair
FCanvasTileItem TileItem( CrosshairDrawPosition, CrosshairTex->Resource, FLinearColor::White);
TileItem.BlendMode = SE_BLEND_Translucent;
Canvas->DrawItem( TileItem );
}

View File

@ -0,0 +1,25 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "CarwatchHUD.generated.h"
UCLASS()
class ACarwatchHUD : public AHUD
{
GENERATED_BODY()
public:
ACarwatchHUD();
/** Primary draw call for the HUD */
virtual void DrawHUD() override;
private:
/** Crosshair asset pointer */
class UTexture2D* CrosshairTex;
};

View File

@ -0,0 +1,13 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class CarwatchEditorTarget : TargetRules
{
public CarwatchEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
ExtraModuleNames.Add("Carwatch");
}
}