# How can I do boolean operations on meshes with UE4?

**URL:** <https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 7, 2014, 3:36pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737 "2014-05-07T15:36:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robi395](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robi395](https://forums.unrealengine.com/u/robi395)\
**Post date:** [May 7, 2014, 3:36pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/1 "2014-05-07T15:36:52Z")

</div>

Hello,

I just started playing with UE4 and i am trying to do run-time mesh edition based on boolean operations.  
For instance, when the player hit a object with is gun, the object should be replaced by “object-SphereOfImpace”. SphereOfImpace being a spherical mesh. (Exemple of boolean operation on meshes: [http://www.flipcode.com/archives/fig4.gif](http://www.flipcode.com/archives/fig4.gif))

I plan on calling a external library to execute the boolean operation.

I don’t think liking to a library should be a issue:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

I have already been able to generate run-time meshes using the following wiki entry:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

I have identified some library ([http://doc.cgal.org](http://doc.cgal.org), [Google Code Archive - Long-term storage for Google Code Project Hosting.](https://code.google.com/p/carve/), [GTS - The GNU Triangulated Surface Library](http://gts.sourceforge.net/index.html), [GitHub - gilbo/cork: 3D Boolean / CSG Library](https://github.com/gilbo/cork)), but i don’t know which one to pick.

Does anyone have any experience with boolean operations on meshes with UE4? Which library is the best suited for my needs (fast and easy even if inacurate)? Is calling a external library the way to go?

Thanks,

Edit: I changed the title to emphasize the boolean operation aspect of my question

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 7, 2014, 5:09pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/2 "2014-05-07T17:09:17Z")

</div>

#Extend Static Mesh Actor

Just extend the static mesh actor class, and use your custom class in your game instead of AStaticMeshActor

#Extending Class

```
UCLASS()
class AYourSMA : public AStaticMeshActor

```

Then your own class can handle all the modifications to itself

#Detect Collisions Against Mesh

Use this function to detect projectile and other collisions, within the class, and then set the new meshes

```
void AVictoryWall::ReceiveHit(
	class UPrimitiveComponent* MyComp, 
	class AActor* Other, 
	class UPrimitiveComponent* OtherComp, 
	bool bSelfMoved, 
	FVector HitLocation, 
	FVector HitNormal, 
	FVector NormalImpulse, 
	const FHitResult& Hit
)
{
	//Hit by Character?
	AVictoryPlayerCharacterBase* IsChar = Cast<AVictoryPlayerCharacterBase>(Other);
	if(!IsChar) return;
	// ~~~~~~~~~

}

```

#Set Mesh

set new mesh this way

StaticMeshComponent-\>SetMesh(new asset);

---

<div class="post-metadata">

**Author:** ![robi395](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robi395](https://forums.unrealengine.com/u/robi395)\
**Post date:** [May 10, 2014, 8:46pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/3 "2014-05-10T20:46:46Z")

</div>

Thank you for your input.

My question was more about the boolean operation on the mesh, and which tools was more suited to do that. Do you have any experience with this kind of problem?

By the way, i’m seen you username in many post relevant to my work. 🙂

---

<div class="post-metadata">

**Author:** ![pikai18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pikai18](https://forums.unrealengine.com/u/pikai18)\
**Post date:** [July 22, 2015, 4:10am UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/4 "2015-07-22T04:10:55Z")

</div>

Hello robi395 !  
My idea is the same with you, I Currently studying Procedural\_Mesh.  
If you have the result, please let me know.Thx!

---

<div class="post-metadata">

**Author:** ![mortmaire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mortmaire](https://forums.unrealengine.com/u/mortmaire)\
**Post date:** [September 4, 2016, 11:17pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/5 "2016-09-04T23:17:58Z")

</div>

I’m working on an answer, currently I have similar problem. Probably I’ll use CGAL or some other library. I’ll post you a code when I finish.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_66e8808f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_66e8808f](https://forums.unrealengine.com/u/anonymous_user_66e8808f)\
**Post date:** [October 12, 2017, 6:46am UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/6 "2017-10-12T06:46:53Z")

</div>

Found this two years old thread by looking to do the same.  
Did you guys manage to static link some boolean mesh code library to Unreal?  
For example Blender is using Carve library and its working pretty well.  
Or do you know some similar functionality already imported to UE4?

---

<div class="post-metadata">

**Author:** ![AlexanderSt](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexanderst/32/465118_2.png) [@AlexanderSt](https://forums.unrealengine.com/u/AlexanderSt)\
**Post date:** [June 1, 2023, 12:10pm UTC](https://forums.unrealengine.com/t/how-can-i-do-boolean-operations-on-meshes-with-ue4/282737/7 "2023-06-01T12:10:04Z")

</div>

there is experimental plugin integrated in Unreal engine - Geometry Script

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/3/5933732c7131cb1c0ebe98e65b313757bf3f7af7.png)

> **[Geometry Script Users Guide](https://docs.unrealengine.com/5.2/en-US/geometry-script-users-guide/)**
>
> A guide to using Geometry Script Fuctions and Blueprint Nodes

Using this tool you can make different boolean operations on mesh with Blueprints or Python  
this is example python script for that - [UE5.0 Geometry Script - Mesh Booleans in Python | Tutorial](https://dev.epicgames.com/community/learning/tutorials/D9x/unreal-engine-ue5-0-geometry-script-mesh-booleans-in-python)  
In Blueprints it look like so:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/9/aa927e9d2338029ca4f5b9bc2d3cb0d59b4772a2.jpeg)

Go to documentation page and read it.
