Hi everyone. So for the past week I have been having issues making my pawn move CORRECTLY. I've looked at multiple different examples but can't get it exactly how I want.
I've tried using SetActorLocation() and had success in making my pawn move but the issue is that it has absolutely no collisions and it passes through everything.
I've tried using the AddMovementInput() but it doesn't affect the position of my StaticMesh pawn at all although the inputs are going through.
I've tried using AddActorLocalOffset() but it makes my Pawn spiral and glitch out of control.
I've tried using the PawnMovementComp's AddInputVector() but it didn't cause any kind of movement.
I really don't know how to get a desired 2D topdown movement while retaining collision. I'm losing my mind. Here is my code for reference. I am just using the SetActorLocation method right now because at least it moves right? I do not even know if this is efficient and any leads as to what I should do would be much appreciated.
// Sets default values
// 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;
AutoPossessPlayer = EAutoReceiveInput::Player0;
//Creates capsule collision as the root component
CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleComponent"));
CapsuleComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
RootComponent = CapsuleComponent;
//Create static mesh component(empty)
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
//CameraBoom->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
CameraBoom->TargetArmLength = 800.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = false; // Rotate the arm based on the controller
CameraBoom->RelativeRotation = FRotator(-60.f, 0, 0);
// 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
//Movement Component being added
ChefMovementComponent = CreateDefaultSubobject<UPawnMovementComponent>(TEXT("MovementComp"));
ChefMovementComponent->UpdatedComponent = RootComponent;
// Called when the game starts or when spawned
// Called every frame
void AFuzzyChefPawn::Tick(float DeltaTime)
FVector NewLocation = GetActorLocation() + (CurrentVelocity * DeltaTime);
// Called to bind functionality to input
void AFuzzyChefPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
PlayerInputComponent->BindAxis("MoveForward", this, &AFuzzyChefPawn::VerticalMovement);
PlayerInputComponent->BindAxis("MoveRight", this, &AFuzzyChefPawn::HorizantalMovement);
void AFuzzyChefPawn::VerticalMovement(float value)
if (Controller != NULL)
CurrentVelocity.X = value * VerticalMoveSpeedMultiplier;
UE_LOG(LogTemp, Warning, TEXT("Vert"));
void AFuzzyChefPawn::HorizantalMovement(float value)
if (Controller != NULL)
CurrentVelocity.Y = value * HorizantalMoveSpeedMultiplier;
UE_LOG(LogTemp, Warning, TEXT("Horiz"));
Jan 19 '18 at 09:20 PM
in C++ Programming