How do I reload a particular weapon ?

Get help using Construct 2

Post » Thu May 28, 2015 5:18 pm

I tried storing the weapon UID and use the pick instance with UID function but it never does reload the weapon in question.
Here is my "code" :
Image

Basically I just use a while to find any magazine not used.
Then use it by toggling the Used boolean.
And pick the weapon that it on the shoulder of the player to reload it by setting the variable AmmoLeft to the max capacity of the weapon.

Result : it doesn't work and I don't really know what to do any help appreciated.

Thanks.
B
6
S
1
Posts: 8
Reputation: 310

Post » Thu May 28, 2015 5:34 pm

I think instead of "while", you meant to use "for each" items
But I'm not sure what you expect this event to do..

If you change the while with for each what it will do is set the boolean of all items that are on layer 2 and are of type ammo and are not used to used..
If the instance of items with uid = player.uid is on layer2, is of the type ammo and is not used it will set it's ammoleft to items.maxammo

what I don't get is how you use the ammo by setting it used..
It doesn't change anything else than it's boolean in this event.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 28, 2015 5:53 pm

My magazines have no capacity because I want ammo to be universal so the player can gather any weapon and never have to worry about ammo type. So the magazine can either be used (empty) or full (not used).

The part that doesn't work is the pick instance one. Switched to a for each didn't solve the fact that pick instance isn't triggered.

Thanks for your answer tho.
B
6
S
1
Posts: 8
Reputation: 310


Return to How do I....?

Who is online

Users browsing this forum: MadSpy and 57 guests