Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

TMap.Find returning random value

This one has me stumped. Looking for a little guidance!!

In header file:

 struct FStatValue
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     int32 MinValue = 0;
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     int32 CurrentValue = 100;
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     int32 MaxValue = 100;

 TMap<EStat, FStatValue> TStats;
 UFUNCTION(BlueprintCallable, Category = "Stat Manager")
 void SetStat(EStat Stat, int32 NewValue, bool Update);

Next I have in my CPP:

 void UF3CMasterStatManager::SetStat(EStat Stat, int32 NewValue, bool Update)
     FStatValue* FS = TStats.Find(Stat);
     if (FS != nullptr)
         FS->CurrentValue = NewValue;
         if (FS->CurrentValue < FS->MinValue)
             UE_LOG(LogTemp, Warning, TEXT("MinValue Override in Uf3CMasterStatManger::ModifyStat"));
             FS->CurrentValue = FS->MinValue;
         else if (FS->CurrentValue > FS->MaxValue)
             FS->CurrentValue = FS->MaxValue;
         //FS->CurrentValue = FMath::Clamp(NewValue, int32(FS->MinValue), int32(FS->MaxValue));
         // If the call asked to update the stat (in child for display purposes)
         if (Update)
         UE_LOG(LogTemp, Warning, TEXT("MasterStatManager: Set Stat Find returned NULLPTR."));

I exploded the Clamp (which is commented out) to see what was actually happening. I set a breakpoint on the UE_LOG line inside the IF. The MinValue is coming back as 512, or 440 or 600 sometimes. and sometimes 0! I scanned all my logic and nowhere do I even attempt to update the default value for MinValue. So it should always be 0.

Product Version: UE 4.19
more ▼

asked May 29 '18 at 07:17 PM in C++ Programming

avatar image

33 2 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question