Hey everyone, I am newbie and I have problem with pawn movement. I want pawn to move in set direction with constant speed but after setting initial velocity it stops after 2 ticks, where could be the problem?
The code:
// Fill out your copyright notice in the Description page of Project Settings.
#include "Ball.h"
#include <GameFramework/FloatingPawnMovement.h>
// Sets default values
ABall::ABall()
{
PrimaryActorTick.bCanEverTick = true;
movementDirection.X = FMath::RandBool() == true ? -1.0f : 1.0f;
movementDirection.Y = FMath::RandBool() == true ? -1.0f : 1.0f;
movementDirection.Z = 0.0f;
BallVelocity = movementDirection * movementSpeed;
movementComponent = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("PawnMovementComponent"));
movementComponent->Velocity = BallVelocity;
UE_LOG(LogTemp, Warning, TEXT("Movement speed constr %f"), movementComponent->Velocity.Size());
}
// Called when the game starts or when spawned
void ABall::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("Movement speed begin1 %f"), movementComponent->Velocity.Size());
movementComponent->Velocity = BallVelocity;
}
// Called every frame
void ABall::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UE_LOG(LogTemp, Warning, TEXT("Movement speed tick %f"), movementComponent->Velocity.Size());
//movementComponent->AddInputVector(BallVelocity, true);
}
// Called to bind functionality to input
void ABall::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}