# How to add groomcomponent via c++ and attach it to skeletal mesh

**URL:** <https://forums.unrealengine.com/t/how-to-add-groomcomponent-via-c-and-attach-it-to-skeletal-mesh/605506>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 15, 2022, 10:52am UTC](https://forums.unrealengine.com/t/how-to-add-groomcomponent-via-c-and-attach-it-to-skeletal-mesh/605506 "2022-07-15T10:52:05Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![scttlsk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@scttlsk](https://forums.unrealengine.com/u/scttlsk)\
**Post date:** [September 7, 2023, 5:05pm UTC](https://forums.unrealengine.com/t/how-to-add-groomcomponent-via-c-and-attach-it-to-skeletal-mesh/605506/3 "2023-09-07T17:05:28Z")

</div>

I had this problem for UE5.2, but regenerating project files didn’t solve it.

Instead I followed:  
[NiagaraDataInterfacePhysicsAsset.h and GroomComponent.h in Unreal 5.1](https://forums.unrealengine.com/t/niagaradatainterfacephysicsasset-h-and-groomcomponent-h-in-unreal-5-1-header-not-found/718705/2)

I solved it by adding both “HairStrandsCore” and “Niagara” to “PublicDependencyModuleNames” in my .Build.cs file.

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-add-groomcomponent-via-c-and-attach-it-to-skeletal-mesh/605506)._
