Whats the best way to remove weapon?

Get help using Construct 2

Post » Fri Oct 02, 2015 1:54 am

If I have a weapon or item attached to a character/sprite and the sprite gets destroyed how do I destroy the item?
Picking nearest seems to cause problems, and if hitting object or overlapping object wont work because it could be overlapping another sprites item who isn't destroyed.

You see my conundrum?

What method do you guys use?
B
10
S
4
G
3
Posts: 223
Reputation: 3,458

Post » Fri Oct 02, 2015 11:14 am

cs2curious wrote:If I have a weapon or item attached to a character/sprite and the sprite gets destroyed how do I destroy the item?
Picking nearest seems to cause problems, and if hitting object or overlapping object wont work because it could be overlapping another sprites item who isn't destroyed.

You see my conundrum?

What method do you guys use?

Since the weapon is a separate sprite and its "link" to a specific character, you can store the Character.UID in the item as a variable. So when your Item or Character gets destroyed. You can pick both the Item or Character based on this:

Code: Select all
The two items:
Item object
Character_UID = 100 (Stored character UID)

Character object
UID = 100

When Item is destroyed:
Item on destroyed
Pick Character.UID = Item.Character_UID
<Do something>

When Character is destroyed:
Character on destroyed
Pick Item.Character_UID = Character.UID
<Do something>
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848


Return to How do I....?

Who is online

Users browsing this forum: minigame, tannerdler, zenox98 and 6 guests