# ShooterGame Demo. Retrieving "CurrentAmmoInClip" from C++ in Blueprint

**URL:** <https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, CPP, Blueprint, question\
**Created:** [August 29, 2018, 12:19pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716 "2018-08-29T12:19:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenryFlewitt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HenryFlewitt](https://forums.unrealengine.com/u/HenryFlewitt)\
**Post date:** [August 29, 2018, 12:19pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/1 "2018-08-29T12:19:21Z")

</div>

I’m trying to retrieve the “CurrentAmmoInClip” data from the C++ Class “Shooter Weapon” (C++ Classes, Shooter Game, Public, Weapons" in order to use this information as an RTPC in Wwise (to change the sound of the gun as ammo decreases).

I’ve looked around for an answer and have been guided to add the variable to the blueprint editor using:

```
/** current ammo in clip */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Ammo)
int32 CurrentAmmoInClip;

```

Which successfully adds this to the config of the weapon, but it doesn’t allow me to create a node that will retrieve the data. Am I missing something? It seems I’ve done everything I need to, As far as I can tell from this guide:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Any ideas? Sorry if this is really simple, I’m quite new to C++.

---

<div class="post-metadata">

**Author:** ![Grocker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grocker](https://forums.unrealengine.com/u/Grocker)\
**Post date:** [August 29, 2018, 12:48pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/2 "2018-08-29T12:48:09Z")

</div>

I think you need to add EditAnywhere or BlueprintReadWrite to the UPROPERTY to edit the variable in the blueprint, currently, you can only read the variable in blueprints

---

<div class="post-metadata">

**Author:** ![HenryFlewitt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HenryFlewitt](https://forums.unrealengine.com/u/HenryFlewitt)\
**Post date:** [August 29, 2018, 2:09pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/3 "2018-08-29T14:09:29Z")

</div>

I don’t need to edit the variable though, I simply want to be able to use the number. This is a great example:

 ![251952-varbpcppnew.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/5/9d5fd458829c0889f9d7edbe94a521ccf4b2f5ff.jpeg)

Whereby “Music Skill Level” would be “CurrentAmmoInClip”. I can’t seem to allow it to create the node for this. I assume it has to be a reference? Similiar to “reference to self”, but the node simply isn’t there to be added to the blueprint.

---

<div class="post-metadata">

**Author:** ![Grocker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grocker](https://forums.unrealengine.com/u/Grocker)\
**Post date:** [August 29, 2018, 2:52pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/4 "2018-08-29T14:52:48Z")

</div>

Have you Context Sensitive on or off ? when you search for the variable.

---

<div class="post-metadata">

**Author:** ![HenryFlewitt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HenryFlewitt](https://forums.unrealengine.com/u/HenryFlewitt)\
**Post date:** [August 29, 2018, 3:02pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/5 "2018-08-29T15:02:02Z")

</div>

I’ve tried with both Context Sensitive on and off. This really has stumped me haha

---

<div class="post-metadata">

**Author:** ![Grocker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grocker](https://forums.unrealengine.com/u/Grocker)\
**Post date:** [August 29, 2018, 3:07pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/6 "2018-08-29T15:07:34Z")

</div>

you can try to add VisibleAnywhere but i don’t really have any idea.

---

<div class="post-metadata">

**Author:** ![Grocker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grocker](https://forums.unrealengine.com/u/Grocker)\
**Post date:** [August 29, 2018, 3:10pm UTC](https://forums.unrealengine.com/t/shootergame-demo-retrieving-currentammoinclip-from-c-in-blueprint/432716/7 "2018-08-29T15:10:07Z")

</div>

or compile your project inside visual studio the ue4 compile work sometimes not right
