How do I make a weapon switching system

Just started using Construct 2? Post your questions here

Post » Fri Aug 15, 2014 2:57 am

Hi. What I'm trying to do is have the player be able to collide with a weapon icon and switch weapons. The player does not keep the weapon they had they only keep the new weapon they picked up. I assume I can use Boolean variables but I don't know how. I also assume I can use an array, but again I don't know how. It works when I do player on collision with power set group to weapon activated, but for multiple weapons this method does not work.Thanks.
B
4
Posts: 6
Reputation: 208

Post » Fri Aug 15, 2014 7:54 am

Have weapon pickup sprite for each weapon, on collision spawn it onto your character and destroy your current weapon + destroy the pick up from the ground
B
32
S
7
G
2
Posts: 317
Reputation: 2,851

Post » Fri Aug 15, 2014 9:58 am

You could add an instance variable weapon to your player (either text or number) and set it to the weapon you want..

player on collision with weapon one - set variable to weapon one (or if you want numbers just 1)

and then something like this:

player if variable = weapon one - set group weapon one activated..
trigger once
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 » Tue Aug 19, 2014 10:59 pm

Thanks guys these were good ideas.

On another subject. What would you do to get a random power up spawner?
B
4
Posts: 6
Reputation: 208

Post » Wed Aug 20, 2014 1:23 pm

I have made a tutorial about random monster loot drops that you should easily be able to adapt to make your own random power up spawner system.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
294
S
117
G
96
Posts: 7,312
Reputation: 71,092

Post » Thu Sep 04, 2014 4:06 am

okay. Now i have another problem. How do I make a text object appear in the center of the screen even when the screen is scrolling to a player?
B
4
Posts: 6
Reputation: 208

Post » Thu Sep 04, 2014 4:39 am

You'll need to make a text object, position it in the centre of the screen and give it the Anchor behaviour. Keep the default value as blank, then you can set the text via events. If you want it to not be obscured by game objects, make a layer above the main game layer called UI and put it there.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Thu Sep 04, 2014 5:12 am

What do you mean by "keep the default value as blank"?

Edit: okay so what you said worked, but one of my files will not show text objects when i run the game. It's visible in the editor, but not in the game. And its on the top layer, and set to visible, i don't know what's going on. is there a know glitch that causes text objects to disappear?
B
4
Posts: 6
Reputation: 208

Post » Fri Sep 05, 2014 8:18 am

jmanziel wrote:What do you mean by "keep the default value as blank"?

Edit: okay so what you said worked, but one of my files will not show text objects when i run the game. It's visible in the editor, but not in the game. And its on the top layer, and set to visible, i don't know what's going on. is there a know glitch that causes text objects to disappear?


Not that I know of. Can you export your project .capx file so I can take a look at debugging it?
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Fri Sep 05, 2014 9:22 am

jmanziel wrote:What do you mean by "keep the default value as blank"?

Edit: okay so what you said worked, but one of my files will not show text objects when i run the game. It's visible in the editor, but not in the game. And its on the top layer, and set to visible, i don't know what's going on. is there a know glitch that causes text objects to disappear?

Have you tried r179? There was a known bug which caused object to be shifted because of parallax, it was fixed in r179, according to Ashley.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests