Download

Problems exposing values to blueprint (shooter gamer)

Hey guys,
I am fairly new to programming or lets phrase it like this: I don’t really know how to handle c++. :smiley:

Anyway, the issue I have is that I want to expose two variables to blueprint, but everytime I cook it fails with the following error:



Error G:/Epic Games/Unreal Projects/DICE_ABC_Test/Source/ShooterGame/Public/Weapons/ShooterWeapon.h(176)  : Missing ';' in 'variable declaration'


So that is the code that I changed. My changes are marked red. You can also look at it in the shooter game code in ShooterWeapon.h at line 175. I didn’t do anything than adding these two lines…



	/** get current ammo amount (total) */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Game)
	int32 GetCurrentAmmo() const;

	/** get current ammo amount (clip) */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Game)
	int32 GetCurrentAmmoInClip() const;


I also uploaded the whole code of the “ShooterWeapon.h” here. In case you are not synct to the shooter game.

I guess there is an easy fix for this. Can anyone enlight me?

They looks like a function to me so shouldn’t it be a UFUNCTION()? and if you want to be able to call these in BP you would use BlueprintCallable as specifier. (you probably want BlueprintPure too if they are just property getters and don’t change any state)

You Sir, are my hero today. Works fine, thx!