Hi, Im learning how to use UE to create games (of course). I
m trying to follow a YouTube tutorial but something went wrong. The game Im trying to create is Breakout. although I Followed the tutorial to a T (except for the names) the paddle in the tutorial moves and mine doesn
t. It`s a C++ tutorial, here is the link for it: https://www.youtube.com/watch?v=LsNW4FPHuZE&t=6648s
It also gives me the error: Failed to load /Game/Materials/CollisionMaterial.CollisionMaterial Referenced by BodySetup_0 when I open Unreal.
Here is the paddle code in the .cpp file:
// Fill out your copyright notice in the Description page of Project Settings.
include “GayMan.h”//(couldn`t add the hashtags)
include “GameFramework/FloatingPawnMovement.h”
include “Components/StaticMeshComponent.h”
// Sets default values
AGayMan::AGayMan()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SM_Paddle = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("meeeeeeeeeeeee"));
RootComponent = SM_Paddle;
SM_Paddle->SetEnableGravity(false);
SM_Paddle->SetConstraintMode(EDOFMode::XYPlane);
SM_Paddle->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
SM_Paddle->SetCollisionProfileName(TEXT("PhysicsActor"));
FloatingMovement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("Floating Pawn Movement"));
}
// Called when the game starts or when spawned
void AGayMan::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AGayMan::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AGayMan::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void AGayMan::MoveHorizontal(float AxisValue)
{
AddMovementInput(FVector(AxisValue, 0.0f, 0.0f), 1.0f, false);
}
And here is the code for the player controller in the .cpp file:
// Fill out your copyright notice in the Description page of Project Settings.
include “jojo_for_the_win.h”//(couldn`t add the hashtags)
include “Kismet/GameplayStatics.h”
include “Camera/CameraActor.h”
include “GayMan.h”
//include “ball.h”
Ajojo_for_the_win::Ajojo_for_the_win(){
//int Score;
}
void Ajojo_for_the_win::BeginPlay(){
TArray<AActor*>CameraActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ACameraActor::StaticClass(), CameraActors);
FViewTargetTransitionParams Params;
SetViewTarget(CameraActors[0], Params);
}
void Ajojo_for_the_win::SetupInputComponent(){
Super::SetupInputComponent();
EnableInput(this);
InputComponent->BindAxis("MoveHorizontal", this, &Ajojo_for_the_win::MoveHorizontal);
}
void Ajojo_for_the_win::MoveHorizontal(float AxisValue){
auto MyPaddle = Cast<AGayMan>(GetPawn());
if (MyPaddle) {
MyPaddle->MoveHorizontal(AxisValue);
}
// rewrite this code so you won`t need to cast it everytime.
}
thanks for the help.