Skip to content

Commit

Permalink
Added Basic Steam Integration Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
orfeasel committed Dec 2, 2016
1 parent f9e20af commit 6b17c8a
Show file tree
Hide file tree
Showing 63 changed files with 2,574 additions and 0 deletions.
3 changes: 3 additions & 0 deletions SteamIntegration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Steam Sample projects

Read the full tutorial here: http://wp.me/p6hvtS-jJ
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions SteamIntegration/SteamIntegrationTut/Config/DefaultEditor.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[UnrealEd.SimpleMap]
SimpleMapName=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap

[EditoronlyBP]
bAllowClassAndBlueprintPinMatching=true
bReplaceBlueprintWithClass= true
bDontLoadBlueprintOutsideEditor= true
bBlueprintIsNotBlueprintType= true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ContentBrowser]
ContentBrowserTab1.SelectedPaths=/Game/ThirdPersonCPP
37 changes: 37 additions & 0 deletions SteamIntegration/SteamIntegrationTut/Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap
EditorStartupMap=/Game/ThirdPersonCPP/Maps/ThirdPersonExampleMap
GlobalDefaultGameMode="/Script/SteamIntegrationTut.SteamIntegrationTutGameMode"

[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
MinimumiOSVersion=IOS_8


[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_ThirdPerson",NewGameName="/Script/SteamIntegrationTut")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_ThirdPerson",NewGameName="/Script/SteamIntegrationTut")
+ActiveClassRedirects=(OldClassName="TP_ThirdPersonGameMode",NewClassName="SteamIntegrationTutGameMode")
+ActiveClassRedirects=(OldClassName="TP_ThirdPersonCharacter",NewClassName="SteamIntegrationTutCharacter")
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")


[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum

[OnlineSubsystem]
DefaultPlatformService=Steam
PollingIntervalInMs=20

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
GameServerQueryPort=27015
bRelaunchInSteam=false
GameVersion=1.0.0.0
bVACEnabled=1
bAllowP2PPacketRelay=true
P2PConnectionTimeout=90
3 changes: 3 additions & 0 deletions SteamIntegration/SteamIntegrationTut/Config/DefaultGame.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=15D66C5E473FAC89ED3925BF7B0E309E
ProjectName=Third Person Game Template
24 changes: 24 additions & 0 deletions SteamIntegration/SteamIntegrationTut/Config/DefaultInput.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[/Script/Engine.InputSettings]
+ActionMappings=(ActionName="Jump", Key=SpaceBar)
+ActionMappings=(ActionName="Jump", Key=Gamepad_FaceButton_Bottom)

+AxisMappings=(AxisName="MoveForward", Key=W, Scale=1.f)
+AxisMappings=(AxisName="MoveForward", Key=S, Scale=-1.f)
+AxisMappings=(AxisName="MoveForward", Key=Up, Scale=1.f)
+AxisMappings=(AxisName="MoveForward", Key=Down, Scale=-1.f)
+AxisMappings=(AxisName="MoveForward", Key=Gamepad_LeftY, Scale=1.f)

+AxisMappings=(AxisName="MoveRight", Key=A, Scale=-1.f)
+AxisMappings=(AxisName="MoveRight", Key=D, Scale=1.f)
+AxisMappings=(AxisName="MoveRight", Key=Gamepad_LeftX, Scale=1.f)

+AxisMappings=(AxisName="TurnRate", Key=Gamepad_RightX, Scale=1.f)
+AxisMappings=(AxisName="TurnRate", Key=Left, Scale=-1.f)
+AxisMappings=(AxisName="TurnRate", Key=Right, Scale=1.f)
+AxisMappings=(AxisName="Turn", Key=MouseX, Scale=1.f)

+AxisMappings=(AxisName="LookUpRate", Key=Gamepad_RightY, Scale=1.f)
+AxisMappings=(AxisName="LookUp", Key=MouseY, Scale=-1.f)

+ActionMappings=(ActionName="ResetVR", Key=R)
+ActionMappings=(ActionName="ResetVR",Key=MotionController_Left_Grip1,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
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.
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class SteamIntegrationTutTarget : TargetRules
{
public SteamIntegrationTutTarget(TargetInfo Target)
{
Type = TargetType.Game;
bUsesSteam = true;
}

//
// TargetRules interface.
//

public override void SetupBinaries(
TargetInfo Target,
ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
ref List<string> OutExtraModuleNames
)
{
OutExtraModuleNames.Add("SteamIntegrationTut");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class SteamIntegrationTut : ModuleRules
{
public SteamIntegrationTut(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

PublicDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemUtils" });

DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "SteamIntegrationTut.h"


IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, SteamIntegrationTut, "SteamIntegrationTut" );

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#ifndef __STEAMINTEGRATIONTUT_H__
#define __STEAMINTEGRATIONTUT_H__

#include "EngineMinimal.h"
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "SteamIntegrationTut.h"
#include "Kismet/HeadMountedDisplayFunctionLibrary.h"
#include "SteamIntegrationTutCharacter.h"

//////////////////////////////////////////////////////////////////////////
// ASteamIntegrationTutCharacter

ASteamIntegrationTutCharacter::ASteamIntegrationTutCharacter()
{
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;

// 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, 540.0f, 0.0f); // ...at this rotation rate
GetCharacterMovement()->JumpZVelocity = 600.f;
GetCharacterMovement()->AirControl = 0.2f;

// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 300.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 MyCharacter (to avoid direct content references in C++)
}

//////////////////////////////////////////////////////////////////////////
// Input

void ASteamIntegrationTutCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
// Set up gameplay key bindings
check(PlayerInputComponent);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

PlayerInputComponent->BindAxis("MoveForward", this, &ASteamIntegrationTutCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ASteamIntegrationTutCharacter::MoveRight);

// We have 2 versions of the rotation bindings to handle different kinds of devices differently
// "turn" handles devices that provide an absolute delta, such as a mouse.
// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("TurnRate", this, &ASteamIntegrationTutCharacter::TurnAtRate);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("LookUpRate", this, &ASteamIntegrationTutCharacter::LookUpAtRate);

// handle touch devices
PlayerInputComponent->BindTouch(IE_Pressed, this, &ASteamIntegrationTutCharacter::TouchStarted);
PlayerInputComponent->BindTouch(IE_Released, this, &ASteamIntegrationTutCharacter::TouchStopped);

// VR headset functionality
PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &ASteamIntegrationTutCharacter::OnResetVR);
}


void ASteamIntegrationTutCharacter::OnResetVR()
{
UHeadMountedDisplayFunctionLibrary::ResetOrientationAndPosition();
}

void ASteamIntegrationTutCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
Jump();
}

void ASteamIntegrationTutCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)
{
StopJumping();
}

void ASteamIntegrationTutCharacter::TurnAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

void ASteamIntegrationTutCharacter::LookUpAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

void ASteamIntegrationTutCharacter::MoveForward(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);

// get forward vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}

void ASteamIntegrationTutCharacter::MoveRight(float Value)
{
if ( (Controller != NULL) && (Value != 0.0f) )
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);

// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Character.h"
#include "SteamIntegrationTutCharacter.generated.h"

UCLASS(config=Game)
class ASteamIntegrationTutCharacter : public ACharacter
{
GENERATED_BODY()

/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;

/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;
public:
ASteamIntegrationTutCharacter();

/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseTurnRate;

/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseLookUpRate;

protected:

/** Resets HMD orientation in VR. */
void OnResetVR();

/** Called for forwards/backward input */
void MoveForward(float Value);

/** Called for side to side input */
void MoveRight(float Value);

/**
* Called via input to turn at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void TurnAtRate(float Rate);

/**
* Called via input to turn look up/down at a given rate.
* @param Rate This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
*/
void LookUpAtRate(float Rate);

/** Handler for when a touch input begins. */
void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location);

/** Handler for when a touch input stops. */
void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);

protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// End of APawn interface

public:
/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "SteamIntegrationTut.h"
#include "SteamIntegrationTutGameMode.h"
#include "SteamIntegrationTutCharacter.h"

ASteamIntegrationTutGameMode::ASteamIntegrationTutGameMode()
{
// set default pawn class to our Blueprinted character
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPersonCPP/Blueprints/ThirdPersonCharacter"));
if (PlayerPawnBPClass.Class != NULL)
{
DefaultPawnClass = PlayerPawnBPClass.Class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/GameModeBase.h"
#include "SteamIntegrationTutGameMode.generated.h"

UCLASS(minimalapi)
class ASteamIntegrationTutGameMode : public AGameModeBase
{
GENERATED_BODY()

public:
ASteamIntegrationTutGameMode();
};



Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.

#include "SteamIntegrationTut.h"
#include "WinTrigger.h"




Loading

0 comments on commit 6b17c8a

Please sign in to comment.