[英]Error with TArray floats in Unreal Engine C++
C++ and Unreal newbie here. C ++和虚幻新手。 I have a class with a function I'm calling from a Blueprint. 我有一个带有从蓝图调用的函数的类。 I want to create an array of floats (converted from a string) and push a value from Blueprint to it, but I'm getting an error I don't quite understand. 我想创建一个浮点数数组(从字符串转换),并将一个值从Blueprint推送到它,但是我遇到了一个我不太明白的错误。
I'm declaring the array like this in my header file: 我在头文件中声明了这样的数组:
private:
TArray<float> SensorValues[5];
Then I try to push a value from my Blueprint in the cpp file: 然后,我尝试从cpp文件中的“蓝图”中推送一个值:
void Test::UpdateSensor(FString SensorValue)
{
float sensorVal = FCString::Atof(*SensorValue);
SensorValues.Push(sensorVal);
}
Which results in this error: 导致此错误:
error C2228: left of '.Push' must have class/struct/union
Any guidance? 有指导吗?
我认为您忘记了包含标题:D
According to documentation TArray is dynamic array, so you should have tried 根据文档,TArray是动态数组,因此您应该尝试
private: TArray<float> SensorValues;
besides 除了
private: TArray<float> SensorValues[5];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.