Do I need to access the Data table every time using its Dir-Reference?

I created this logic and I am accessing the Data table Directory everytime to access its directory, so my Question is it not possible to access its rows using the already declared pointer to the data table called row

	if (_bCrouching)
	{
		if (!_bHoldWeapon && (MoveForwardAxis != 0.0f || MoveRightAxis != 0.0f))
		{

			//Get the Camera height row from data table of Camera Height Row and set the value to the new height from this.
			if (const UDataTable* DT_CameraHeight{ LoadObject<UDataTable>(GetWorld(), TEXT("DataTable'/Game/Blueprints/BP_DataTables/Camera/DT_CameraHeight.DT_CameraHeight'")) })
			{
				//Set camera height for crouch normal move
				if (const FST_CameraHeight* Row{ DT_CameraHeight->FindRow<FST_CameraHeight >("Crouch_Normal_Move", "") }) //60
				{
					_NewHeight = Row->Height;
					printf("The new value for NewHeight from Crouch_Normal_Move is: %f", _NewHeight);
				}
			}

			else
			{
				if (_bHoldWeapon && (MoveForwardAxis != 0.0f || MoveRightAxis != 0.0f))
				{

					//Get the Camera height row from data table of Camera Height Row and set the value to the new height from this.
					if (const UDataTable* DT_CameraHeight{ LoadObject<UDataTable>(GetWorld(), TEXT("DataTable'/Game/Blueprints/BP_DataTables/Camera/DT_CameraHeight.DT_CameraHeight'")) })
					{
						//Set camera height for crouch Rifle move
						if (const FST_CameraHeight* Row{ DT_CameraHeight->FindRow<FST_CameraHeight >("Crouch_Rifle_Move", "") }) //80
						{
							_NewHeight = Row->Height;
							printf("The new value for NewHeight from Crouch_Rifle_Move is: %f", _NewHeight);
						}
					}
				}
			}
		}
	}

you should be able to access any row under the data table using your pointer someVariable = Row->Height; if you are under the same loop I think. cheers

2 Likes

Thank You, its working ) and what if I want to access it in other conditions outside of the loop?

const UDataTable DT_CameraHeight{ ************ };* Declare this line globally in the top of the function or create it as a global class to access it anywhere, you can also make a macro of it to access it easity. cheers

2 Likes