How do I create a weapon change

0 favourites
  • 5 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Since my original question at the beginners section seemed to go nowhere, i figureg i might step it up a bit and ask basically the same thing here.

    Im trying to create a game similar to crimsonland where you have hordes of enemy coming at you and you try your best to keep them at bay until the inevitable defeat. The player has only one weapon to use at any given time, but can change the weapon if anotherone is spawned to the playfield.

    What i would want to create, is the player to have a max of two weapons at his/her disposal. a primary, and a secondary weapon. That he could change should an enemy drop one for example.

    Where i've gotten so far, is that i have the player start off with nothing. he can pick up two weapons that shoot their own bullets and the weapons can be changed through mousescroll. Now on the mousescroll change, i have a bit of an issue that i cannot seem to figure out. The weapons on the ground react to the mousescroll before i've even picked the up. How would i set it so they only react to the mousescroll if equipped by the player? Another issue is the bullets. I've got a shotgun on the game that shoots a burst of pellets. Problem is, all of the pellets dissapear after only one hits an enemy or goes over the grid. I assume this would be related to the fact that the bullet has a container that has the rest of the pellets attached to it.

    The gamefiles can be found at https://www.dropbox.com/sh/j9xxg9strbnfw5z/AADeIzHrZkAt_mDV036b7Klaa?dl=0 to see what i mean. Or https://dl.dropboxusercontent.com/u/73502848/New%20project/index.html to test the game on a browser.[/code:3v0x27fb]
    ^-- i guess im not allowed to post url:s , but im assuming im not hurting anyone here by going around the blocking like this..
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Fastest solution would be to add pinned condition, like in picture.

    Although you will need something more complex if you add more weapons.

  • Two weapons demo

  • That not all of your bullets get destroyed, make sure you pick every single one.

    For example:

    -For each Bullet

    -- On collision with Monster ~ Bullet Destroy

    I can't imagine for what reason you've created a container for your shotgun pellets.

    Try to remove it, because according to my knowledge it would destroy all others as well as long as they're within the same container.

    and for the weapon pick up.

    Simply add a "equipped" boolean instance variable to the weapons.

    Then add a check when switching weapons.

    If "equipped" True

    With that you can prevent that you set them invisible while they're still on the floor

  • Thanks razor monkey for the advice, that worked like a charm, now that i see that, its so obvious i feel silly.

    Everade, im not entirely sure why i used that container in the first place. Guess i sort of though that a shotgun shell is a container of pellets..sooo anyway, changed it so that each pellet has its own destroy on collision state. Works fine now, thanks! I didnt try this boolean thing just yet as Razor monkeys advice worked great, however. Now that i got the two weapons to work like i want, im curious if this way i could use more than two weapons at a time?

    Lordshiva, thanks for that. I remember you posting a reply to the other thread as well. However, this type of weaponchange does not really work with my project. Much appreciated nonetheless.

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