I’m trying to add Buoyancy pontoons to a ship in C++.
I can do it in BP.
My Flotation component is created.
If I activate r.Water.DebugBuoyancy I see the red spheres on the included test cube, but not on my C++ Ship.
I’m calling the function AddBuoyancy() in OnConstruction. But I have tried it in the construct as well (with createdefaultsubobject) with same negative result.
The hull is the root, But I can’t see a command to attach the flotation to the root. In the BP childclass I see that the Flotation is separated by a line (?) and there is no details for it.
void AShipTemplete::AddBuoyancy()
{
UBuoyancyComponent* Flotation = NewObject<UBuoyancyComponent>(this);
if (Flotation)
{
Flotation->RegisterComponent();
Flotation->AddCustomPontoon(80, FVector(400, 0, 40));
}
else {
UE_LOG(LogTemp, Warning, TEXT("There is no Buoynacy component added"));
}
}