x

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"

In ShooterGame how can I access the current ammo amount?

I am trying to access how much ammo the player in carrying thru the blueprint but I cannot figure out what to create to do this. I searched for a var called either ammo or clip. I have found neither and then of course this has to be specific to the weapon / player. Things I am trying to accomplish are. If the weapon is dropped it should still have the same ammo in it if picked up. But the additional ammo is it attached to the player or the weapon? I do not need to change this either way but I am not sure what results to expect. How can I access a var from the weapon blueprint to affect the carrying player? i would like to do this in the weapons blueprint as with having many weapons it would be painful to put have to setup something simple if each weapon already has a default val stored in it.

thanks

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 05:23 AM in Everything Else

avatar image

ue4-archive ♦♦ STAFF
50k 3670 1999 9124

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

1 answer: sort voted first

Dear Emile,

In ShooterWeapon.h, the base class for all the weapons :

 /** get current ammo amount (total) */
 00160: int32 GetCurrentAmmo() const;
 00161:
 00162: /** get current ammo amount (clip) */
 00163: int32 GetCurrentAmmoInClip() const;
 00164:
 00165: /** get clip size */
 00166: int32 GetAmmoPerClip() const;
 00167:
 00168: /** get max ammo amount */
 00169: int32 GetMaxAmmo() const;


You can just add

UFUNCTION(BlueprintPure, BlueprintCallable)

to these and you should be good to go

:)

:)

Rama

more ▼

answered Mar 11 '14 at 05:23 AM

avatar image

ue4-archive ♦♦ STAFF
50k 3670 1999 9124

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 05:23 AM

the function you put up threw up errors as lack of category I used this instead and it compiled fine.

 00159: /** get current ammo amount (total) */
 00160: UFUNCTION(BlueprintCallable, Category=Weapon)
 00161: int32 GetCurrentAmmo() const;


Thanks for the help Rama

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 05:23 AM

if your issue is resolved please mark the check by my answer so others know it is solved :)

yea sorry about the category part, forgot that :)

RAma

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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