Weapon Reloading

Hi I’m making an ammo check script for my weapon and all it’s ok but there’s a little stupid problem that I don’t know how to workaround.

This is what happen when I pickup a magazine, it adds +30 to my current ammo variable but if I spawn more than 1 ammo entity on the ground the first will be RifleAmmo (so if I pick that it’ll give me + 30 bullets) but the second is RifleAmmo2 the third RifleAmmo3 ecc… so how I can replace get display name with something better? I tried object name but every entity has still a different name.

Hey there,

Instead of using the display name, try using tags.

In the magazine blueprint, give the actor a tag such as “RifleAmmo”. Then, in your function above, you’d check the actor’s tag for “RifleAmmo” instead of display name. These tags won’t change with each spawn.

Hi man , you probably dont want check the name, but the class ! ( or for mutlipleactor check inside a variable! )
When you spawn a Magazine, you probably use ““spawn actor from class (Magazine)”” and he will create an actor magazine0, magazine1 magazine2…
Instead of asking for the name , ask for the class of your actor.

I have an actor called All_Pickup, this actor have a int named Type and i can set it from 0 to 6 so in the begin event,
he will get the statick mesh of a bottle, of a ammo , of a healtpack and so on…
when my character enter in the actor All-pickup i use, get actor, and then i use Cast_to all_pickup
and then i ask for my int, using get Type to know which special item i have found.
hope its clear

thank you very much for your answers. In the end I fixed that adding a socket on the mesh and checking in the blueprint if the static mesh of the actor had that socket (whoever need that the name of the node is Does Socket Exist)