How do I make multiple weapon upgrades with one object?

0 favourites
  • 10 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hello, I have kind of a niche question. I am making a game where you can upgrade your weapons by parts and want to know if it's possible to make multiple weapons share one object for a given part, via animations. For example, I have a part called 'shotgun_front_upgrade' that is always assigned to be in front of my shotgun via image point. It has three separate one-frame animations: One for when there is no front-upgrade, one for a silencer, and one for a cork (don't ask).

    (seen here)

    These two upgrades go to different guns (both are coincidentally shotguns), but I don't know how to set the animation back to 'Blank' when the upgrade is not visible (I.E., when the player has a different weapon out). I tried using an 'Else' statement seen here:

    (the silencer upgrade)

    But this only works for one gun. If I apply an Else statement to another gun, they override each other if the upgrades are enabled at the same time.

    |

    (for example, here is shotgun 2 with the silencer upgrade, shotgun 3 is on the right with no upgrade selected)

    |

    (upon enabling shotgun 3's upgrade, the Else statement applies to all other guns and the shotgun 2 upgrade is overridden)

    So my question is: How do I make it so that the correct animation appears with the correct object in situations like this? And, if that's not possible for whatever reason, how would you recommend I go about making multiple upgrades for the same gun part?

  • Are the Blank, Silencer, and Cork (too funny) actual animations?

    If they aren't animations then why not simply use frames? Copy and paste your shotgun (or upgrade part holder) into the editor and copy it, then right click in frames bar and add new frame, paste the shotgun in and put a silencer on it, repeat for cork. Now you have a shotgun plain (frame 1), shotgun silenced (frame 2), and shotgun corked (frame 3). Now you can simply change frames when you want the right upgrade showing.

    I would make the upgrade part an object that is simply an invisible box with frames representing all my upgrades. Assign it a pin behavior so it could be spawned and pinned to either weapon via an event and then all you would need to do it tell it when to show the appropriate frame.

  • Unfortunately I get the same issue (though that does save some space, thank you!). When I select the gun with the silencer and then switch to another gun, it should go away, but for some reason (a real obvious reason I'm probably missing :p) it stays visible.

    (an unrelated gun with the silencer from shotgun 2, just to show off the specific problem I'm having)

  • How are you making it go away? Are you resetting the frame to an empty frame or setting the entire object invisible?

    If you are doing either checked to see where in the event chain you are doing this, sometimes moving it up above other actions will cause it to work.

    Also, make sure you have zeroed out all the default animation controls which I believe are set to run once. I have had issues with it switching mine to end frame until I zeroed them out.

  • Similarly to the OP, I've got it set as an Else statement, just instead of animations I have it set to frames. Is there some other action I can use to set it back to 0 upon switching weapons or having out a weapon that does not have the front end upgrade enabled? As is, the problem is that switching to the weapon with an upgrade sets the animation to that upgrade's animation frame, but switching weapons does not set it back to frame 0, and I'm not sure how to do that.

  • Frames have their own control actions like animations. They will be available to any object with multiple frames detected.

    Without seeing more of what your trying to do I can't determine what might be causing your exact issue. Can you put up a .capx file of just the gun swapping events?

    I can throw you together a capx of how I would do this, but without knowing how your tying it all in it might not help you with what your ultimate vision is.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sure, here is my .capx for the file I'm using to test game mechanics. Press 'P' to open the pause menu and click 'Upgrades' to show the upgrade buttons. Press 'C' to cycle through guns.

  • Here is a quick .capx I threw together of what i was talking about with frames, maybe you can find something in it to help with your project.

  • Ah, your example cap helped me figure it out. I had events/variables for when there IS a front upgrade, but no variable for when there ISN'T a front upgrade. That hole in the logic made it so that setting the animation to frame 0 did nothing on guns that don't have a front upgrade at all. That's why the upgrade still appeared for the unrelated shotgun a few posts up, because it has no attachment to the front upgrade object. So, I did this:

    (the new shotgun 2 silencer upgrade code)

    I created a variable called "no_front_upgrade", which by default sets the animation of shotgun_front_upgrade to frame 0 like so:

    All I had to do then was make it so that, when a gun has a front upgrade, no_front_upgrade is set to 0 (as seen in the code above) when that gun is currently in the player's hand. Then, the Else statement sets no_front_upgrade back to 1 when switching weapons. If the next weapon has a front upgrade, it is then re-set to 0, and so on. Now it works perfectly! Thanks for the help!

  • Glad my stickmen could help you get it working!

    Looks like a really cool project!

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