Hi, Im new to UE and learning to create Breakout through a tutorial on YouTube. But for some reason even though I did the same as the tutorial my paddle didn
t move while his did (this is a UE C++ tutorial). My paddle stays at the center and disappears after pressing the left/right arrow a few times.
Here is the paddle class code in the .cpp file (ignore the stupid names):
#include "GayMan.h"
#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"));
}
void AGayMan::BeginPlay()
{
Super::BeginPlay();
}
void AGayMan::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
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 in the player controller .cpp file:
#include "jojo_for_the_win.h"
#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);
}
}
Thank you for you help.
,Hi, I`mbc new to UE and learning to create Breakout