CJacobsSA's Forum Posts

  • Hello, I'm having an issue with creating enemies for my game, more specifically how they are animated. Since the enemies will have complex animations (running, firing their guns, standing still, etc) I created an enemy box to spawn and assign them to as I would for a player character. I gave the box the platform behavior so that it can be moved.

    (the purple 'E' box in this screenshot)

    The box has a variable called 'Direction' that controls which direction the box is facing, 'left' or 'right'. When the box collides with the GoLeft and GoRight boxes (the blue ones with arrows in the screenshot above), it turns around and goes the opposite way and sets 'Direction' to the new direction it is moving in.

    What I want to have happen is, when the box is facing left, the sprite for the enemy (the dinosaur lookin' dude in the screenshot above) attached to the box is mirrored, and when it is facing right, the sprite is not mirrored (since they face right by default).

    The trouble is that I have no idea how to accomplish that. Movement I have down pat; when I have multiple boxes they all move and correspond with the GoLeft/Right boxes properly. The sprites attached to them on the other hand, when I try to set them to be mirrored, do... er, this:

    (oh god help I'm so lost here)

    If you can't tell what's happening, the sprites are flipping around whenever ANY enemy box hits ANY GoLeft or GoRight box. Notice that the mirroring on the boxes behind the sprites is working totally fine.

    So my question is: How do I make it so that, when a box changes direction, it ONLY affects the sprite pinned to it and not the others?

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

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

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

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

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

  • Haha, wow, don't I feel stupid. I was putting it in the wrong place. Thanks a bunch!

  • Hi there, I'm mostly here to look for help on using Construct 2 because I'm a total noob at it, but if I see anything interesting to post about elsewhere I'll probably contribute.

  • After doing some bug testing it appears that a_shotgun_x is the culprit. When this line is enabled in the code:

    the shotgun does the angle thing it was doing above because:

    a_shotgun_x does not reset to 0. If I set it to reset to 0 in the action where the gun fires, it will only shoot 1 pellet for god knows what reason. I've officially given up on trying to explain why this is in words so here, I'll just upload my dev .capx and let you guys play around with it if anyone's interested in finding out what's wrong and/or want to explain how to fix it.

    After doing some bug testing it appears that a_shotgun_x is the culprit. When this line is enabled in the code:

    the shotgun does the angle thing it was doing above because:

    a_shotgun_x does not reset to 0. If I set it to reset to 0 in the action where the gun fires, it will only shoot 1 pellet for god knows what reason. I've officially given up on trying to explain why this is in words so here, I'll just upload my dev .capx and let you guys play around with it if anyone's interested in finding out what's wrong and/or want to explain how to fix it.

  • Based on post from nimos, I assumed you implemented it, LocalVariable always reset to it's default value, while StaticVariable does not, so you need to reset those variable in the For loop action to make it behave similarly to your old version.

    This does sound like it would work, but I'm not sure I understand what I need to do to reset the variable to what it was before and still have the gun be upgrade-able. If you could go a bit more in-depth I'd appreciate it.

    If you made more than one "codebox_shotgun_stats" you need to pick the correct one first. Note, you don't need the "Group is active" test as that code can only be reach IF the group is active!

    Thanks for the tip, redundancy removed!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Update: Now that I've made the changeover and re-written the code, other things have broken! Previously the shotgun fired straight out of the barrel at the angle I set:

    (old code method)

    But now when I fire, this happens:

    (new code method)

    I can't tell at a glance what has changed or what I did wrong in the crossover, so I'll post both the new and old shotgun fire code and let people more experienced than me take a look at it (you'll probably have to open them in a new tab to view them in full, they're big and I don't have enough posts to use URLs yet).

    (old code, note the variables being part of the group)

    (new code, variables are a part of a sprite called 'codebox_shotgun_stats')

  • Ahh, that does seem like a clever way of doing things. I'll try that. Thank you for the quick reply!

  • EDIT: THE ISSUE IN THIS POST HAS BEEN SOLVED. SEE A COUPLE POSTS DOWN FOR THE NEW ONE I'M HAVING. (didn't want to make a whole new thread)

    I'm making a game where you can upgrade the various statistics of your weapons, and to organize it better and make things work consistently I have organized the weapons' stats and firing patterns into groups:

    (ignore the names and stuff, this is just from my early dev file)

    Inside each group are a bunch of variables that pertain to the stats of each weapon as well as the math that determines what they do:

    (the player will be able to upgrade or change each of these numbers)

    If I place a button inside the group I can change the number, but all of my upgrade buttons and my pause menu are in a separate group because they have to be in order to be usable. So, is it possible to change a global number that is inside a different group, or will I have to do some reorganizing? If it isn't possible, how would you recommend I go about fixing/reorganizing it?