CJacobsSA's Forum Posts

  • Hi! I'm making a breakout clone (well, it's a breakout clone right now) and I'm having a bit of trouble. The paddle is controlled by the mouse, but unlike being controlled by keys, I can't figure out a way to keep it within the boundaries (the green boxes). Currently it's set to just always follow the mouse's X position, which obviously won't work. As is, it's fine with just going right past the boundaries and off the screen.

    I have also tried making a big sprite/tiled bg and making it so the paddle only follows the mouse when it's over the sprite, i.e. inside the boundaries. But that only kind of worked, because moving too fast from one end to the other causes the mouse to leave the sprite before the paddle catches up to it on the next frame.

    I'm probably just having a brain fart, but I really can't figure it out. Any advice?

  • Ah, thank you! I figured it was just an expression I was overlooking. I was searching 'pick' when I should've looked for 'choose'. Much appreciated.

  • Relatively simple question, I hope. I'm sure it can be done, but I just can't figure out what I need to type to make it so.

    Let's say for example that my enemy has 5 attacks that it can do at various ranges. At close range, it can do attacks 1, 3, and 5. But at long range it can do 2, 4, and 5. In these cases, doing round(random(1, 5)) wouldn't work, because that would include the possibility of the other ranges' attacks in the result. I also can't rearrange the animations themselves, because there'd be no way to include attack #5 in both besides duplicating it, which I'd rather avoid. Is there a value I can type in to just say "set the variable to 1, 3, or 5"? Or do I have to do a workaround of some kind?

  • Thank you all for the suggestions! They were all very informative and helpful.

  • In my game, the player will be able to purchase upgrades to objects on specific layouts that persist throughout the game. In this case, an item in the player's house increases the filling speed of their EXP bar. The codebox is a global object that keeps track of variables that are important such as what level the upgrade-able objects are at, and what bonuses to distribute. The upgrade itself works just fine, the problem is that it triggers lines 105 and 107 again every time the player changes to a different layout. So the +5 to mainbar_speed becomes +10 on changing layout, then +15, etc.

    What am I doing wrong here? I assumed trigger once meant only once, but it seems to mean once on the current layout.

  • EDIT: Never mind, I realized just now that I had the enemy's attack animation set to repeat, so line 55 never triggered even though it appeared like it did thanks to line 56! Whoops!

    Hi, in my game I would like for enemies to follow through with their attacks, instead of aborting them when the player gets out of range. The problem I'm having has a lot to do with how I have my enemy's code and state changing set up, I think. Here is the code for my example enemy:

    As is, line 56 makes it so that when the player gets out of range, the enemy goes back to the 'active' state and stops attacking. I'd like to remove this line and replace whatever I need to in order to make it so that if the enemy is attacking, they don't change states until the current attack is done. But I can't figure out for the life of me how to change my code to make that happen!

  • edit: moved to its own thread as it is a different question entirely

  • Thank you, that fixed the problem! I figured it'd be a pretty simple solution. I sometimes forget that actions execute every tick unless you manually tell them not to.

  • Hi, I've got a pretty simple question pertaining to some odd behavior by the enemies I've created.

    It has two LOS behaviors: A big one that sets it active (Enemy01los01), and a smaller one that tells it to attack (Enemy01los02. When the player leaves the smaller one, it's supposed to set the enemy back to the walking animation, and it only sort of does. The enemy gets stuck at the beginning of the walk animation for a few seconds before it fixes itself, and I can't figure out why.

    Here is the entirety of the enemy's code. Anything jump out that could be the culprit?

  • Ahh, thank you for the explanation! That's a big help, I appreciate it.

  • Oh, interesting! I reversed the order of the two upgrade actions and now it works just fine. I guess order of operations is more important than I thought. Thank you!

  • Hello, I've got a weird logic quirk that you folks can surely help me unravel. I want my game to have certain upgrades be repeatedly buyable for a number of ranks. This seemed like it'd be easy, but it's proving to be pretty tricky.

    The way I've got this set up, what I expected to happen is: when the player clicks the button, if var_isbought is 0 it does the first upgrade and then sets it to 1, and stops. What I figured is that it would only perform the action that is true when the player first clicks the button, but it turns out that's not the case. Instead, it continues to the second upgrade and makes that change as well. How do I make it work like I intend for it to?

  • Unfortunately neither solution works; with Aher0's, it just flat-out does not create the 01top and 01bottom objects. I think the reason for that is that the obj_enemy00s aren't created, they're spawned, which is a weird technicality? Maybe? And Gmoney's solution would work, but it's incompatible with my current spawning system.

    is there a way to add the second enemy to my array system and skip spawning the enemy_00 entirely? I think that might work.

    Here is the event that spawns enemies from the spawners. Basically it takes whatever is at the front of the spawnlist array (pushed there in the previous step of the spawn process) and creates an obj_enemy00 with the 'type' variable set to whatever the array says. Is there a way to make it something like, say, "if spawnlist says 'tankguy', spawn obj_enemy01 instead"?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, I've got a weird problem I can't figure out how to solve. My game is an arena shooter where enemies are created from a number of spawners with the logic set up basically like so: Every x seconds, create obj_enemy_00 at the spawner with y dedicated ID variable, et cetera. For just spawning a single object (the base enemy object), this works great! The trouble comes when I try to spawn an enemy with multiple parts.

    The way I have it set up, obj_enemy_00 has a variable called 'type' which determines what kind of enemy it is when it is spawned. The tank guy has a couple extra bits that I need to create when it spawns, but I can't figure out how. If I do this:

    it only creates one of each no matter how many tank guys I push out of the spawners. If I do this:

    it creates a scary feedback loop that, for reasons unknown to me, spawns hundreds of them per second (it does this with and without the extra "type = tankguy").

    The system is relatively complex so it'd probably be easier for you to just poke around in the .capx to see if you can figure out the problem, you can download it here. I'm hoping I'm just having a brain fart and the answer is real simple.

  • This is how I handled the issue.

    Subscribe to Construct videos now

    Thank you! This is exactly what I was looking for, I feel like a dummy for not trying it. <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    To avoid jittering movement, it's best to use a proper AI follow code.

    To stop an enemy AI from jittering, we could use a variable like this.

    https://www.dropbox.com/s/1g0lseyx71z9h ... .capx?dl=0

    My recommendation is to use a simple set of events with variables like my next example.

    By the way, I made this myself.

    https://www.dropbox.com/s/iwftjcj2izc6j ... .capx?dl=0

    1. Try approaching the enemy to be on enemy's line of sight.

    2. Get caught. Enemy will stop.

    3. Run away. Enemy will stay in the stopped state.

    4. Approach the enemy again to provoke. Enemy will follow again.

    Right now I don't have any enemies that would need this complex of an AI but I'll keep it in mind in case I ever do!