no suitable constructor exists to convert from "double" to "UE::Math::TVector<double>"

Hey Y’all, Im trying to make a flappy bird game, and I want to clamp the players X axis, however, whenever i try to do so, i get this error:
no suitable constructor exists to convert from “double” to “UE::Math::TVector”
Here is the code for the tick function,

void AFlappyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if(IsValid(FlappyBirdREF))
	{
		FlappyBirdREF->AddForce(FVector(-700.0f, 0.0f, 0.0f), NAME_None, true);
		float MyMaximumSpeedValue = 1000.0f;
		CurrentVelocity = FlappyBirdREF->GetPhysicsLinearVelocity();
		FVector CurrentVelocityX = CurrentVelocity.X;
		FVector clampedVelocity = CurrentVelocity.GetClampedToMaxSize(MyMaximumSpeedValue);
		FlappyBirdREF->SetPhysicsLinearVelocity(clampedVelocity.XAxisVector, true);
	}

}

CurrentVelocity.X is a double (just the value of the X coordinate.)

You might do something like:

FVector CurrentVelocityX(CurrentVelocity.X, 0, 0);

Thanks so much!

1 Like
void AFlappyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if(IsValid(FlappyBirdREF))
	{
		FlappyBirdREF->AddForce(FVector(700.0f, 0.0f, 0.0f), NAME_None, true);
		float MyMaximumSpeedValue = 1000.0f;
		CurrentVelocity = FlappyBirdREF->GetPhysicsLinearVelocity();
		FVector CurrentVelocityX(CurrentVelocity.X, 0.0f, 0.0f);
		FVector clampedVelocityX = CurrentVelocityX.GetClampedToMaxSize(MyMaximumSpeedValue);
		FlappyBirdREF->SetPhysicsLinearVelocity(clampedVelocityX, true);
	}

}

The Bird now accelarates extremly fast, completly ignoring the clampedvelocity, why is this happening?

Nvm, Fixed it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.