# Resize of StaticMesh using C++

**URL:** <https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963>\
**Category:** C++\
**Tags:** size, unreal-engine, scale, staticmesh, CPP, question\
**Created:** [November 30, 2017, 8:55am UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963 "2017-11-30T08:55:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SvarogZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SvarogZ](https://forums.unrealengine.com/u/SvarogZ)\
**Post date:** [November 30, 2017, 8:55am UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/1 "2017-11-30T08:55:51Z")

</div>

The task is to change the size of StaticMesh from C++.

There is base C++ class. StaticMesh is choosed from BP class.  
I want to use the same BP for different sizes.

From Blueprints I can do it here (see picture). Is it possible to do the same from C++ for one copy only? Or advise the way to do it proper. Textures should not be resized.

 ![221971-question.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/c/ccc50585d726dd9561c53cb6315d167c2931c76e.jpeg)

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [November 30, 2017, 10:13am UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/2 "2017-11-30T10:13:03Z")

</div>

Not Sure exactly what you want, why don’t you simply scale the component ? (UStaticMeshComponent)

```
UStaticMeshComponent* staticMesh;
staticMesh->SetWorldScale3D(FVector(2, 2, 2));
staticMesh->SetRelativeScale3D(FVector(2, 2, 2));
```

---

<div class="post-metadata">

**Author:** ![SvarogZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SvarogZ](https://forums.unrealengine.com/u/SvarogZ)\
**Post date:** [November 30, 2017, 10:54am UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/3 "2017-11-30T10:54:26Z")

</div>

In that case textures on the edges are stretched also.

![221979-question2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/c/a7cf50029be4afbb4cbfacd9e2197abe20021b7d.jpeg)

---

<div class="post-metadata">

**Author:** ![Napoleonite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Napoleonite](https://forums.unrealengine.com/u/Napoleonite)\
**Post date:** [November 30, 2017, 11:32am UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/4 "2017-11-30T11:32:13Z")

</div>

You could change the material so that the edges won’t stretch.

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [November 30, 2017, 12:32pm UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/5 "2017-11-30T12:32:08Z")

</div>

![222001-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/a/67af4c3d59819b6b280e03756aaca77596c304e9.jpeg)

Now i know what you whant, I would recommend you to do it in material to avoid having to manually code dynamic scaling.

Material has a TextCood node, multiply it with the object scale node and ‘voila’

You should keep a correct scale ratio. but i don’t think there is a magic solution for that case

---

<div class="post-metadata">

**Author:** ![SvarogZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SvarogZ](https://forums.unrealengine.com/u/SvarogZ)\
**Post date:** [December 7, 2017, 8:52pm UTC](https://forums.unrealengine.com/t/resize-of-staticmesh-using-c/410963/6 "2017-12-07T20:52:58Z")

</div>

Yes. Thank you.

I can’t do exactly the same.  
I have to use one BP material.

There are 3 materials (one for opposite sides of a cube).

 ![222942-question5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/5/a15f068762422ed6975bf75b544cabcacacb69f0.jpeg)

DataAsset contains size scale, material and other information.

 ![222943-question4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/7/7c7baacf4c92f1a3dbcf5e8ece8deff7444d2ac4.jpeg)

Using C++ I can change any scale of the cube and adjust UVs in BP already.

 ![222944-question3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/c/82c9648d0ec8ab3d0f372ea6eb667298f5d829f5.jpeg)
