# UProperty min & max values?

**URL:** <https://forums.unrealengine.com/t/uproperty-min-max-values/312957>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 28, 2015, 5:26pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957 "2015-03-28T17:26:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zeldhoron](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zeldhoron](https://forums.unrealengine.com/u/Zeldhoron)\
**Post date:** [March 28, 2015, 5:26pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957/1 "2015-03-28T17:26:33Z")

</div>

Is there a way to set a min and/or max value for a UProperty in a C++ class ?

```
UPROPERTY(EditAnywhere, Category = "Camera")
	float CameraMinPitch;

UPROPERTY(EditAnywhere, Category = "Camera")
	float CameraMaxPitch;

```

So the min pitch should be between -89 & 0.  
Max pitch should be between 0 & 89.

---

<div class="post-metadata">

**Author:** ![Grogger](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grogger](https://forums.unrealengine.com/u/Grogger)\
**Post date:** [March 28, 2015, 5:53pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957/2 "2015-03-28T17:53:51Z")

</div>

What you’re looking for is UIMin/UIMax and ClampMin/ClampMax. Something like this should work:

```
UPROPERTY(EditAnywhere, Category = "Camera", meta = (ClampMin = "-89.0", ClampMax = "0.0", UIMin = "-89.0", UIMax = "0.0"))
float CameraMinPitch;

```

UIMin/Max clamps the slider and ClampMin/Max clamps the actual value

---

<div class="post-metadata">

**Author:** ![Ryan\_Darcey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ryan\_Darcey](https://forums.unrealengine.com/u/Ryan_Darcey)\
**Post date:** [December 22, 2015, 8:15pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957/3 "2015-12-22T20:15:02Z")

</div>

FWIW…I found that just using the ClampMin/Max keys clamps both the actual value and ui slider.

---

<div class="post-metadata">

**Author:** ![Dexgecko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dexgecko](https://forums.unrealengine.com/u/Dexgecko)\
**Post date:** [June 28, 2018, 7:20pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957/4 "2018-06-28T19:20:57Z")

</div>

A list of UPROPERTY meta specifiers can be found here:

> **[Metadata Specifiers](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Metadata/)**
>
> Metadata keywords used when declaring UClasses, UFunctions, UProperties, UEnums, and UInterfaces to specify how they behave with various aspects of Unreal Engine and the editor

> **[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 — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [June 28, 2018, 8:56pm UTC](https://forums.unrealengine.com/t/uproperty-min-max-values/312957/5 "2018-06-28T20:56:07Z")

</div>

Note that that metadata won’t prevent for this property to have out of range value, since they still standard C++ primitive types which you can not passively limit, or else property editor is only palce where this property is set. You need to write limitations on your own in the code for that via some set functions.
