# How change "Float Curve" key value?

**URL:** <https://forums.unrealengine.com/t/how-change-float-curve-key-value/1861685>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 18, 2024, 10:03am UTC](https://forums.unrealengine.com/t/how-change-float-curve-key-value/1861685 "2024-05-18T10:03:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Belketh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Belketh](https://forums.unrealengine.com/u/Belketh)\
**Post date:** [May 18, 2024, 10:03am UTC](https://forums.unrealengine.com/t/how-change-float-curve-key-value/1861685/1 "2024-05-18T10:03:42Z")

</div>

Hello.

Is it possible to change the Float Curve key value using Blueprint?  
If not, is it even possible to programmatically change the value of the Float Curve key?

---

<div class="post-metadata">

**Author:** ![Belketh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Belketh](https://forums.unrealengine.com/u/Belketh)\
**Post date:** [May 20, 2024, 8:19am UTC](https://forums.unrealengine.com/t/how-change-float-curve-key-value/1861685/2 "2024-05-20T08:19:53Z")

</div>

I found a solution. I want to share it with you.  
To do this, you need to create a custom node using C++.  
If you do not use C++ in your project, then you need to download Visual Studio. You can read the instructions here: [Setting Up Visual Studio Development Environment For C++ Projects In Unreal Engine | Unreal Engine 5.1 Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine?application_version=5.1)  
After installation:

1. Open your project - Tools - New C++ class

2. All classes - BlueprintFunctionLibrary - Next  

3. Set the name of your library - Create Class  

4. If VS does not open then go to your project folder and there should be a file [YourProjectName].sln. Open it.  
In Solution Explorer: Game - [YourProjectName] - Source - [YourProjectName] - Open [YourLibraryName].cpp and [YourLibraryName].h  
If VS opens then [YourLibraryName].cpp and [YourLibraryName].h will be open.

5. In [YourLibraryName].h paste code:

```auto
#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Curves/CurveFloat.h"
#include "[YourLibraryName].generated.h" /*Replace [YourLibraryName] with your library name*/

UCLASS()
class [YourProjectName]_API U[YourLibraryName] : public UBlueprintFunctionLibrary /*Replace [YourProjectName] with your project name in capital letters. Replace [YourLibraryName] with your library name*/
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, Category = "My Custom Function")
	static void SetFloatCurveKeyValue(UCurveFloat* Curve, float Time, float NewValue);

};

```

1. In [YourLibraryName].cpp paste code:

```auto
#include "[YourLibraryName].h" /*Replace [YourLibraryName] with your library name*/

void U[YourLibraryName]::SetFloatCurveKeyValue(UCurveFloat* Curve, float Time, float NewValue) /*Replace [YourLibraryName] with your library name*/
{
    if (!Curve) return;

    // Find a key that matches a given time
    FKeyHandle KeyHandle = Curve->FloatCurve.FindKey(Time);

    // If the key is not found, add a new key
    if (KeyHandle == FKeyHandle::Invalid())
    {
        Curve->FloatCurve.AddKey(Time, NewValue);
    }
    else
    {
        //Changing the value of an existing key
        Curve->FloatCurve.UpdateOrAddKey(Time, NewValue);
    }
}

```

1. Save all
2. In Solution Explorer: Game - [YourProjectName] - Right click - Build
3. If everything went well, then you can find your node in the blueprint:  
 ![SFCKVNode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/0/6209e7346712421dcfed7e062a839827cc65b3bf.png)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 19, 2024, 8:20am UTC](https://forums.unrealengine.com/t/how-change-float-curve-key-value/1861685/3 "2024-06-19T08:20:36Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
