FCPlantDefinition definition;
Sometimes I assign ‘definition.PlantState = FPlantState::FPlantState_PlantedSmall’, its value will go back to FPlantState::FPlantState_Available. I am sure there is only one place to change PlantState.
Anyone has same issue before, thanks ~
We’ll need to see more code (like where does ‘definition’ come from?) related to how you’re assigning to the member to provide any help. If it’s a “sometimes”, have you identified the assignments that aren’t working and could share that code.
=======================
Where to check state:
CFFarmLevelMng holds an array of CFFarmPlantActor, it will call the method ‘ManualTick’ defined in CFFarmPlantActor.
void ACFFarmLevelMng::Tick(float DeltaTime) {
Super::Tick(DeltaTime);
for (auto It = PlantMap.CreateConstIterator(); It; ++It) {
ACFFarmPlantActor* Actor = It.Value();
Actor->ManualTick(DeltaTime);
}
}
After SetState(FPlantState::FPlantState_PlantedSmall) is called in ‘Plant_Implementation’,
TPlantDefinition.PlantState is expected to be ‘FPlantState::FPlantState_PlantedSmall’ and its value is still ‘FPlantState::FPlantState_Available’.
That would seem to indicate that your Plant function probably isn’t being called. Or SetState is being called multiple times a frame, first to something non-zero and then to zero. You’ve got log output in SetState, are you seeing that in your logs?
Have you tried setting any breakpoints?
None of your logic or other setup looks obviously wrong (though I’ve only looked at what you posted, not your linked zip file). So you’ve likely got a logic error somewhere with the way your skill and/or FarmLevelMng is working. But it’s very difficult for someone to help you with that remotely.