How do I make multiple weapon upgrades with one object?

Get help using Construct 2

Post » Mon Sep 29, 2014 6:04 am

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

Image
(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:

Image
(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.

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

Image | Image
(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?
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Mon Sep 29, 2014 6:12 am

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.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Mon Sep 29, 2014 6:27 am

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.

Image
(an unrelated gun with the silencer from shotgun 2, just to show off the specific problem I'm having)
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Mon Sep 29, 2014 6:40 am

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.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Mon Sep 29, 2014 6:50 am

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.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Mon Sep 29, 2014 6:59 am

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.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Mon Sep 29, 2014 7:11 am

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.
You do not have the required permissions to view the files attached to this post.
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Mon Sep 29, 2014 7:31 am

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.
You do not have the required permissions to view the files attached to this post.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701

Post » Mon Sep 29, 2014 7:50 am

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:

Image
(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:

Image

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!
B
18
S
9
Posts: 103
Reputation: 1,817

Post » Mon Sep 29, 2014 7:54 am

Glad my stickmen could help you get it working! :)

Looks like a really cool project!
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
71
S
19
G
8
Posts: 640
Reputation: 9,701


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests