# How can I change the size of an UMeshComponent using C++?

**URL:** <https://forums.unrealengine.com/t/how-can-i-change-the-size-of-an-umeshcomponent-using-c/282582>\
**Category:** Asset Creation\
**Tags:** unreal-engine, Blueprint, CPP, question\
**Created:** [May 5, 2014, 5:35pm UTC](https://forums.unrealengine.com/t/how-can-i-change-the-size-of-an-umeshcomponent-using-c/282582 "2014-05-05T17:35:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_44db827a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_44db827a](https://forums.unrealengine.com/u/anonymous_user_44db827a)\
**Post date:** [May 5, 2014, 5:35pm UTC](https://forums.unrealengine.com/t/how-can-i-change-the-size-of-an-umeshcomponent-using-c/282582/1 "2014-05-05T17:35:29Z")

</div>

Hey! I was wondering if I can manipulate the Mesh like I can in Blueprint (adjusting its size, position and rotation like I could with a blueprint mesh component). Just asking, because I really prefer using C++ and am not to keen into learning how to use Blueprint only to use it a few times for Mesh components.

Here is my script:

```
/** Mesh component in the head script */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Mesh)
	TSubobjectPtr < class UStaticMeshComponent> MeshComp;

	// Create the mesh component (in the execution script)
	MeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Collectable"));
	MeshComp->SetOnlyOwnerSee(false); // all players will see this meshs
	MeshComp->bCastDynamicShadow = true;
	MeshComp->CastShadow = true;

```

Thank you in advance!

---

<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 5, 2014, 7:16pm UTC](https://forums.unrealengine.com/t/how-can-i-change-the-size-of-an-umeshcomponent-using-c/282582/2 "2014-05-05T19:16:13Z")

</div>

#SceneComponent.h

What you want is SceneComponent.h! (A Mesh Component is a Scene Component)

```
/** Set the location of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetRelativeLocation(FVector NewLocation, bool bSweep=false);

	/** Set the rotation of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetRelativeRotation(FRotator NewRotation, bool bSweep=false);

	/** Set the transform of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetRelativeTransform(const FTransform& NewTransform, bool bSweep=false);

	/** Returns the transform of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	FTransform GetRelativeTransform();

	/** Set the transform of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void ResetRelativeTransform();

	/** Set the non-uniform of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetRelativeScale3D(FVector NewScale3D);

	/** Adds a delta to the translation of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void AddRelativeLocation(FVector DeltaLocation, bool bSweep=false);

	/** Adds a delta the rotation of this component relative to its parent */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void AddRelativeRotation(FRotator DeltaRotation, bool bSweep=false);

```

#World Space

The above are in Relative Space relative to Parent

You can also set World Space location and rotation

```
/** Set the relative location of this component to put it at the supplied location in world space. */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetWorldLocation(FVector NewLocation, bool bSweep=false);

	/** Set the relative rotation of this component to put it at the supplied orientation in world space. */
	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetWorldRotation(FRotator NewRotation, bool bSweep=false);

	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	void SetWorldScale3D(FVector NewScale);

	UFUNCTION(BlueprintCallable, Category="Utilities|Orientation")
	/** Set the transform of this component in world space. */
	void SetWorldTransform(const FTransform& NewTransform, bool bSweep=false);

```

Enjoy!

Rama

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_44db827a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_44db827a](https://forums.unrealengine.com/u/anonymous_user_44db827a)\
**Post date:** [May 5, 2014, 7:29pm UTC](https://forums.unrealengine.com/t/how-can-i-change-the-size-of-an-umeshcomponent-using-c/282582/3 "2014-05-05T19:29:06Z")

</div>

Thanks, looks very detailed! 🙂
