How to pick up weapons(help,capx included)

Get help using Construct 2

Post » Fri Dec 14, 2012 6:08 pm

I've been trying to get this code working for a few weeks with no success. ive read some posts but still don't understand certain codes that some have provided. i have included the capx file on this thread.

In the file, you'll only be able to pick up the Bat, since i was testing it. Another thing is that when youre overlapping another weapon, youll still be able to pick up the Bat.

I've included 11 weapons, i want to be able to pick up each weapon individually without picking up multiple instances at the same time.
Basically, the simple pick up and drop weapon.

https://dl.dropbox.com/u/101797089/WeaponInstances.capx
B
10
S
4
G
3
Posts: 46
Reputation: 3,036

Post » Fri Dec 14, 2012 6:34 pm

I can't look at your capx right now, but you might want to try a variable like 'holdingWeapon' or something which is true if he has a weapon, and is checked to be false before he picks up a weapon.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Dec 14, 2012 6:57 pm

[QUOTE=sqiddster] I can't look at your capx right now, but you might want to try a variable like 'holdingWeapon' or something which is true if he has a weapon, and is checked to be false before he picks up a weapon.[/QUOTE]

Thanks for the reply. It's little more complicated than that my friend. Whenever you have free time i would love if you checked the capx.
B
10
S
4
G
3
Posts: 46
Reputation: 3,036

Post » Fri Dec 14, 2012 7:15 pm

I'm using an older version of C2 so can't check it myself.

I'd probably use holdingWeapon to store the UID of the weapon sprite. Then only one weapon can be held at a time. You said it's a little more complicated than what sqiddster suggested, so not sure if my suggestion would work, but you never know!
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Dec 14, 2012 8:30 pm

I'm sorry, but it's very hard to find out what your code is doing, considering its size and lack of comments.

If you could make a stripped-down capx with only the problem you are referring to, that will make it much easier for us to help. I'm sure you understand.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Dec 14, 2012 8:32 pm

Iplaygames is using a pickup variable already and it does determine if its picked up or not. Perhaps someone else can look at the capx and see what can be fixed.
B
21
Posts: 23
Reputation: 2,429

Post » Fri Dec 14, 2012 8:40 pm

I believe the problem is the melee intances group and the pick up group. Iplaygames is basing the id of a weapon based on the sprite that is randomly generated at the start of layout.

If a bat is selected, the bat will have a weaponttype value of 1, if its a crowbar it will be 2 and so on.

In the pickup up group, which is just one line of code its where I think the problem lies. Its basically if your overlapping the melee object and press down it will pick It up. But its not very specific so it can pick up any weapon. Should values be used to identify a certain sprite or maybe something else?

B
21
Posts: 23
Reputation: 2,429

Post » Fri Dec 14, 2012 8:55 pm

OK... now why do your weapons all have the platform behavior? That seems really odd to me and the code is very confusing.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Dec 14, 2012 9:11 pm

Thinking more about it now after reading the discussion after my reply, I can say yes, it'd be better to store each weapon with its own value.

currentWeapon = "gun"
and "gun" would be the name of the sprite so it would be easier to match and pick. At least that's how I did it in a shooter I started in CC. The problem with using values to represent the weapontype is it's harder to read through events and debug.

Unless I'm still misunderstanding because I can't check out the capx.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Dec 14, 2012 10:11 pm

The platform behavior was a way to get gravity working for the melee objects, it could be done many ways actually. But the goal is to pick up only one instance of a weapon without picking up the rest.
B
21
Posts: 23
Reputation: 2,429

Next

Return to How do I....?

Who is online

Users browsing this forum: makkancs and 24 guests