MoveVelocity is 0 in RequestDirectMove

I have made this small method here:

void ASPAITankController::MoveTowardsPlayer()
{
	if (!GetPlayerTank())
	{
		UE_LOG(LogTemp, Warning, TEXT("%f: Playertank unknown for AI: %s"), CURRENTTIMESTAMP, *GetName());
		return;
	}
	auto position = GetPlayerTank()->GetActorLocation().ToString();
	UE_LOG(LogTemp, Warning, TEXT("%f: Playertank location: %s"), CURRENTTIMESTAMP, *position);
	MoveToActor(GetPlayerTank(), DistanceAcceptanceRadius);
}

As you can see, i am already looking, if i have a tank and have a position of its actor, then moving to actor.
The Method is called, doing this here:

void UTankMovementComponent::RequestDirectMove(const FVector & MoveVelocity, bool bForceMaxSpeed)
{
	// No need to call super, as we are replacing functionality here
#ifdef DEBUGREQUESTDIRECTMOVE
	auto TankName = GetOwner()->GetName();
	auto MoveVelocityString = MoveVelocity.ToString();
	UE_LOG(LogTemp, Warning, TEXT("%f: Ai  %s intends to move to:  %f"), CURRENTTIMESTAMP, *TankName, *MoveVelocityString);
#endif // DEBUGREQUESTDIRECTMOVE
}

But ! Somehow my MoveVelocityString is 0 and i don’t know why !
Surely i have set the header, otherwise it wouldn’t compile:

	virtual void RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed) override;
LogTemp: Warning: 33.406063: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.406063: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.421963: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.421963: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.437019: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.437019: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.451992: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.451992: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.467331: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.467331: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.483078: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.483078: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.497971: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.497971: Ai  BP_SPTank_7 intends to move to:  0.000000
LogTemp: Warning: 33.514236: Ai  BP_SPTank3_4 intends to move to:  0.000000
LogTemp: Warning: 33.514236: Ai  BP_SPTank_7 intends to move to:  0.000000

I had a typo in the debug, but it does not log ordinary, even if it works somehow.

I must still do something wrong:

void UTankMovementComponent::RequestDirectMove(const FVector & MoveVelocity, bool bForceMaxSpeed) 
{
	// No need to call super, as we are replacing functionality here
#ifdef DEBUGREQUESTDIRECTMOVE
	auto TankName = GetOwner()->GetName();
	auto MoveVelocityString = MoveVelocity.ToString();
	UE_LOG(LogTemp, Warning, TEXT("%f: Ai  %s intends to move to:  %s"), CURRENTTIMESTAMP, *TankName, *MoveVelocityString);
#endif // DEBUGREQUESTDIRECTMOVE

	auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal();
	auto AIForwardIntention = MoveVelocity.GetSafeNormal();

	auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention);
	IntendToMoveForwad(ForwardThrow);

	auto RightThrow = FVector::CrossProduct(TankForward, AIForwardIntention).Z;
	IntendTurnRight(RightThrow);

#ifdef DEBUGTHROW
	auto TankName = GetOwner()->GetName();
	auto MoveVelocityString = MoveVelocity.ToString();
	UE_LOG(LogTemp, Warning, TEXT("%f: Ai  %s intends to move with forward throw:  %f  and right throw: %f"), CURRENTTIMESTAMP, *TankName, ForwardThrow, RightThrow);
#endif // DEBUGTHROW

}

Privacy & Terms