speewave
(speewave)
May 20, 2014, 1:12am
1
So i’m trying to create a basic Actor based class
A Coin, you pick it up, you get X amount of points (as decided by a variable)…
In BP this is a fairly simple thing, but in C++ It won’t work like expected,
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Actor)
int CoinValue;
Is what i have so far, and i keep getting compiler errors that say ‘unrecognized type ‘int’’
Bool works, int8 works (yet shows up as a Bad type in BP editor), but int won’t work
speewave
(speewave)
May 20, 2014, 1:20am
2
I see! Thanks for the help!
use int32
EDIT:
Or, you could have an enum to represent the different values assuming they are static. Like what I did for item types:
UENUM(BlueprintType)
enum SubitemType
{
food UMETA(DisplayName = "Food"),
drink UMETA(DisplayName = "Drink"),
healing_potion UMETA(DisplayName = "Healing Potion"),
posion_potion UMETA(DisplayName = "Posion Potion"),
fire_potion UMETA(DisplayName = "Fire Potion")
};
Rama
(Rama)
May 20, 2014, 1:16am
4
#Dont Use Type Int
This was just recently addressed here:
Here’s a sample code snippet: UFUNCTION() int SomeFunc(); This results in a compiler error saying unknown type int. However, returning float, or types like int32, int16, etc… works. Are we not allowed to return int itself from UFUNCTION...
Dont ever use type int!
and dont use int8 in blueprints, its not working yet
Use uint8, int32, uint32 for maximum happy happy
#UE4 Documentation Link
"Don’t use the C++ int type in portable code, since it’s dependent on the compiler how large it is."
Rama
Rama
(Rama)
May 20, 2014, 1:21am
5
you’re welcome!
please check mark my answer and other people’s answers when your question is resolved so Epic knows the situation is under control
Why is using the float type acceptable?
One quick addition to Rama’s reply. Do not use uint32
for Blueprint as it is unsupported type. Only data types supported by Blueprints are uint8
, int32
and float
.
See this reply from Epic for more info: Missing support for uint32 int64 uint64 - C++ - Unreal Engine Forums
too bad uint doesnt work with blueprint