0 Favourites

How do I change weapons

  • I must be blind, but i cannot seem to find any tutorial that would explain how do you do a weapon change system to a game. To be more spesific, id like the player to have a maximum of two weapons and to be able to change them with the mouse scroll. I fiddled around some and managed to get the player to grab a weapon that it walks over to, but im clueless on how you would change the type of ammo it shoots. Say a pistol shoots one bullet at a time and a shotgun gives out a burst of pellets.

    Cheers!

  • Create a variable (Weapon) associated with the weapon type. Then create statements with dual conditions.

    Button > On click > Player > Spawn Object > Bullet

    System > Weapon = "Gun"

    Button > On click > Player > Spawn Object > Many Bullets

    System > Weapon = "Shotgun"

    When the mouse scroll changes, changes the value of the variable or when he picks up a new weapon.

    Hope this helps

  • Well i got all the way up to getting the player to fire two types of ammo (with different mousebuttons :/ ) but the sroll change just doesnt seem to open up for me. Could i see a working example somewhere perhaps?thats as far as i got

  • So a bit of an update as i've veered a little bit closer to the answer it seems. I finally got the two weapons to change with mousescroll and shoot their own bullets. A few problems reside.

    For some reason, when i shoot at the enemy with the shotgun, all of the pellets dissapear as soon as one hits an enemy. I dont understand why since i've put a destroy order on each pellet separately if they hit the enemy.

    The bigger issue is still with the weapon change. I got it to work kinda fine. The only thing is, now if i use the mousescroll before even taking a weapon from the ground, they switch places (scroll up, shotgun dissapears and rilfe appers and vice versa) how can i get the scroll switching to work only after i've actually piced up the weapons?

  • You're on the right track. Your problem is in your reasoning process.

    Did you understand and use variables as I outlined to defines which weapon fires?

    The reason all your pellets are being destroyed at once is because of the sequencing of your code.

    Try

    Pellet > On collision with(whatever) > Destroy pellet

    Can you PM me with a link to your capx and I'll download it and take a look. I know what the mechanics of your issues is, I'm just not understanding how use the scrolling.

    And is it only 2 weapons you need to switch between or do you need more than 2?

  • Thanks for your time, ill pm you. In the long haul, id like the game to be more versatile and have more than two weapons, but im just learning the program and just trying to figure out how the thing works so for now two weapons will suffice untill i get the knack of it The idea i have is however so that the player can only carry a maximum of two weapons at a time and could drop them to change into another (say an enemy weapon for example)

    Edit: Seems like im not allowed to PM just yet. I put the files on dropbox so you should be able to see it from the address below

    https://dl.dropboxusercontent.com/u/73502848/ryss%C3%A4n%20kosto%20ver2/New%20project.caproj[/code:u6dgrz2i]
  • Since it's been almost three days without any answer, i'm hoping no one takes offence if i bump this thread as im still at a loss. Weapons on the ground dissapear without before picking them up and another one is that if both weapons are picked up, i dont know how to make the one currently selected to stay and the one picked up to dissapear (as to go to your inventory sort of).

    Also as TheDom asked if i need only the two weapons or more, is there a crucial difference in this? just wondering if im making the whole thing somehow wrong if id like to make another game with more weapons in the future with the same principle.

    Quite supprised actually that it seems a bit hard to get an answer for this. I was almost sure there have been a million games made with the same idea as far as the multiple weapons go and my question would have been aswered with a sigh of "not this question again..."

  • Juicy sorry for late reply here try this

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks for that, but it doesnt still quite address my problem. The original question i figured out allready, i just need to iron out a few kinks still. Perhaps the file link i posted would better explain my dilemma. I'm thinking now that i would maybe need an inventory system to the game for this and therefore maybe this question is not suited in the beginners forum?

    (even though im am very very beginner still)

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