In the picture,why [RunningTime] can be used without setting a value?Because of [BeginPlay()]?
Hello,
This does seem incorrect, as on that line where DeltaHeight is being declared/defined, RunningTime would be 0.0f. What tutorial is this from? It could be that the translated page is out of date while the default English one is correct.
Edit: After looking over this again, looking at what it seems to be doing, this looks to be intended. RunningTime is being set every tick to track how long it has been running. It should start off at 0 and be added to every tick.
I found this tutorial from [https://docs.unrealengine.com/latest/INT/Programming/QuickStart/4/index.html]
It also has English version and uses Unreal Engine 4.9.In fact, it work properly.I don’t know whether it is official tutorials.
Thank you for the link. As I mentioned in my edit above, the RunningTime seems to be working correctly. If you look at this earlier part of the tutorial and check step 3, it’ll mention that RunningTime is meant to track the time. This means it’ll start at 0, which is the default value for a float when it is a normal variable and not a pointer, and then be added to every tick.
Thank you for your patient answer.What really puzzled me is when [RuningTime] is setted to 0.In C++,the variable in class wouldn’t be setted to 0 unless I write “=0”.However, in this tutorial,I can’t find where it was assigned a value.Is it UE4’s mechanism?
I could be wrong from simply working in UE4 for too long, but from that I understand, if an Int variable (not a pointer to an Int variable) is declared without specifying a value, you can assume that it is 0 and this is the case in C++ in general. If you would rather be sure, you could set it to 0 in the constructor if you wish, or set it directly as it is being declared.
I wrote a demo to validate my thought.I don’t mean to chase dead end but it really was very strange for me when I contacted UE4 the first time.At present, I probably guess it’s UE4’s some mechanism.
That would be because you’re using a pointer. If you otherwise just reference the value directly, you wouldn’t receive garbage data. In the BeginPlay function, you’re getting these values from within the class and not using a pointer to the class to reference them.