How do I Make a Top-Down Weapon Switching system?

Get help using Construct 2

Post » Sat Aug 20, 2016 1:52 am

I'm trying to make a top down game in which the player starts unarmed and picks up a gun. and i want it to be able to cycle back and fourth. and so when ever he picks up another gun you will be able to cycle between all 3. How would i go about doing that?


Example.

There are 3 Weapons in the game

You start with a Weapon ID Of 0

Then You Pickup a Weapon with the ID of 1 Then you are only able to cycle between those 2

Until

You Pickup a 3rd weapon. Then You Will be able to cycle through all 3 weapons.

You could say use an array. i already have one but if i cycle through it will give me all weapons. :(

Thanks! :D
B
22
S
6
Posts: 26
Reputation: 1,354

Post » Sat Aug 20, 2016 4:16 am

You probably want some instance variables on your player to keep track of what guns they have. Then add a condition, only allow switching to that weapon if the weapon is acquired.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Sat Aug 20, 2016 5:02 am

oosyrag wrote:You probably want some instance variables on your player to keep track of what guns they have. Then add a condition, only allow switching to that weapon if the weapon is acquired.

If i do that, will i have to get rid of my array? I like how my weapon Switching system works there.
B
22
S
6
Posts: 26
Reputation: 1,354

Post » Sat Aug 20, 2016 5:37 am

Without seeing how your events are currently set up, I have no way of answering that question.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Sat Aug 20, 2016 1:40 pm

What oosyrag said. I don't think you need an array for a simple 3 weapon - weapon switch in my newbie opinion. I would use (and have used) variables to switch between weapons.

I think this tutorial might help you build your weapon switch system. Think of switching weapons as switching between different states.

https://www.scirra.com/tutorials/158/ve ... two-states

This might be relevant too though I haven't seen the entire 2 parts.

https://www.youtube.com/watch?v=MFFnqf9 ... Zly6CB8naA
B
28
S
14
G
21
Posts: 179
Reputation: 13,548

Post » Sun Aug 21, 2016 2:47 am

heyguy wrote:What oosyrag said. I don't think you need an array for a simple 3 weapon - weapon switch in my newbie opinion. I would use (and have used) variables to switch between weapons.

I think this tutorial might help you build your weapon switch system. Think of switching weapons as switching between different states.

https://www.scirra.com/tutorials/158/ve ... two-states

This might be relevant too though I haven't seen the entire 2 parts.

https://www.youtube.com/watch?v=MFFnqf9 ... Zly6CB8naA

Thanks!
B
22
S
6
Posts: 26
Reputation: 1,354

Post » Sun Aug 21, 2016 4:52 am

Create a variable called WeaponFrame and create too a object called weapon go to the event sheet and set it: every tick - Weapon set frame WeaponFrame,and forever if you go change the weapon change the variable for example, When I press 1 - WeaponFrame set 1
I want have helped
(Sorry my english i'm not american)
B
4
S
1
Posts: 1
Reputation: 302


Return to How do I....?

Who is online

Users browsing this forum: sublimate and 2 guests