0 Favourites

How do I make a weapon switching system

  • 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.

  • 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

  • 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

  • Thanks guys these were good ideas.

    On another subject. What would you do to get a random power up spawner?

  • 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.

  • 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?

  • 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.

  • 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?

  • 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?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • Sorry I took so long to respond. I think I understand why my text is disappearing. When I put the text object at the top left corner of the layout I can see text objects when i run the file. But is there any way to expand that area? I'm talking about the square that has the dotted lines.

  • Sorry it took so long to reply. I think I understand why the text objects were not visible. I was placing them outside of the top left corner of the layout. I was placing them outside of the dashed lines that form a square. Now I have another question. Can you expand this area?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)