Create a curve based on a mathematical equation

Unreal has math functions built in- though it isn’t exactly a curve, you can sample it just the same.

	int32 GetTotalExpCost(int32 Level)
	{
		// y=x^2
		//return FMath::Pow(Level, 2.0);

		// y = log_2(Level)
		//return FMath::Log2(static_cast<double>(Level + 1));

		// y = log_3(Level)
		//return FMath::LogX(3.0, Level + 1);
	}
	
	int32 GetNextLevelExpCost(int32 Level)
	{
		return GetTotalExpCost(Level) - GetTotalExpCost(Level - 1);
	}

The +1 is only necessary if you’re starting at level 0 and are using a logarithm.

I wrote this in cpp, but the exactly same can be done in blueprint via the exact same methods:

1 Like