So I have this piece of code which checks if two floats are opposite in their signs e.g. one is negative and other is positive vise versa. I feel there must be an easier way to do it than this.
// Checking if force applied is in opposite direction to movement of ball to apply greater force
if (BallVelocityComponents.X > 0 && Value < 0)
{
FVector ForwardVector(Value * ForceApplied * 1500, 0.f, 0.f);
StaticMesh->AddForce(ForwardVector);
}
else if (BallVelocityComponents.X < 0 && Value > 0)
{
FVector ForwardVector(Value * ForceApplied * 1500, 0.f, 0.f);
StaticMesh->AddForce(ForwardVector);
}
else
{
FVector ForwardVector(Value * ForceApplied * 1000, 0.f, 0.f);
StaticMesh->AddForce(ForwardVector);
}
std::signbit, this is what you are looking for.