
EASY UNREAL ENGINE MOVEMENT || Unreal Engine Tutorial
In this video, Emily shows how to program player movement in C++ for the Unreal engine. Stick around and subscribe if you want to learn the unreal engine, and how to make a simple escape room game.
If you would like to use our assets to follow along, they are available here for free: https://opengameart.org/content/escape-room-pack
If you have any questions join us on discord or comment below!
Join our discord server! https://discord.gg/6mgJjTh
Follow us on Social Media!
Instagram: https://www.instagram.com/keysmashstudios/
Twitter: https://twitter.com/KeySmashStudios
Code in Video:
Character_Controller.h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "GameFramework/Actor.h"
#include "GameFramework/Character.h"
#include "Components/InputComponent.h"
#include "Character_Controller.generated.h"
UCLASS()
class ESCAPEROOM_API ACharacter_Controller : public ACharacter
{
GENERATED_BODY()
public:
ACharacter_Controller();
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
void Horizontal_Movement(float axis);
void Vertical_Movement(float axis);
}
Character_Controller.cpp
#include "Character_Controller.h"
ACharacter_Controller::ACharacter_Controller()
{
PrimaryActorTick.bCanEverTick = true;
}
void ACharacter_Controller::BeginPlay()
{
Super::BeginPlay();
}
void ACharacter_Controller::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ACharacter_Controller::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
InputComponent->BindAxis("MoveX", this, &ACharacter_Controller::Vertical_Movement);
InputComponent->BindAxis("MoveY", this, &ACharacter_Controller::Horizontal_Movement);
InputComponent->BindAxis("CameraSide", this, &ACharacter_Controller::AddControllerYawInput);
InputComponent->BindAxis("CameraUp", this, &ACharacter_Controller::AddControllerPitchInput);
}
void ACharacter_Controller::Horizontal_Movement(float axis)
{
if (axis)
{
AddMovementInput(GetActorRightVector(), axis);
}
}
void ACharacter_Controller::Vertical_Movement(float axis)
{
if (axis)
{
AddMovementInput(GetActorForwardVector(), axis);
}
}
Outro Music:
Track: Rival x Cadmium - Willow Tree (feat. Rosendale) [NCS Release]
Music provided by NoCopyrightSounds.
Watch: https://youtu.be/kddC4gi72UE
Free Download / Stream: http://ncs.io/WillowTreeYO