Add pontoons in runtime

Hey guys! For UE’s new water system (4.26), I would like to know if it is possible to add/move buoyancy points (pontoons) dynamically during runtime via blueprints or C++ (without editing source files). Thanks :slight_smile:

Late answer but still, I tried this today and it is actually very easily possible!

To do it, add a new C++ class that inherits BuoyancyComponent.

To your new class, add a function like so:

 UFUNCTION(BlueprintCallable, Category = Buoyancy)
  void AddPontoon(FName PontoonCenterSocket, FVector PontoonRelativeLocation, float PontoonRadius) {
	FSphericalPontoon pontoon = FSphericalPontoon();
	pontoon.CenterSocket = PontoonCenterSocket;
	pontoon.RelativeLocation = PontoonRelativeLocation;
	pontoon.Radius = PontoonRadius;
	BuoyancyData.Pontoons.Add(pontoon);
}

Inside blueprint, use your new component instead of the standard Buoyancy Component and Add Pontoons dynamically!

According to my tests so far, you can even add them after activation. The AutoActive is kinda buggy though, so I keep it off and Activate the Component through blueprint. Deactivate works too.

I also tried to pass the FSphericalPontoon struct directly into the function which kind of worked at first, but everytime I restarted the engine, it recombined the pin and saw the node as error, and after refreshing it twice and again splitting the struct pin, I had to reenter everything. I think having it pass only primitives is fine too.

Should be able to implement a delete function too or maybe even expose the Pontoons array through a getter directly so you can directly manipulate it in blueprint.

3 Likes

works perfectly, thank you. Those were also my first lines of C++ in unreal and I will use it more often from now on, it’s really simple after you get the hang of it. Also I can solve a bug with physics constraints too so hooray

Isn’t there a way to do it with blueprint now? I wish this function was built in.
I have tried this method but I can only get datas :