Vallar's Recent Forum Activity

  • I think the loop runs instantly like within the tick which is why loopindex is 0 then the Wait kind of queues up the events after it because it's asynchronous. I don't expect to get normal results when I add a Wait in a loop but I believe this is what happens.

    For enemy spawner behaviour you could try using Timer behaviour on the enemy spawner object itself, this is what I used and gives nice control over system loop.

    It baffles me that something like "Wait" would mess up loops so much, like if it is a problem, why not disallow waiting in a loop? There are tons of "you can't do this while doing that" warning messages in C3, why isn't this one of them? Just venting though.

    What is weird, is that the Every X loop has the same weird behavior and it doesn't have a wait. Unless you count "Every X" as a wait and in this case, the thing is broken by design.

    Something is odd in how loops function in C3 compared to other engines. I come from Unity and this nonsense doesn't happen there and you could easily add a "wait" to your heart's content or whatever.

  • Hello everyone,

    I created a for loop that looks like this:

    https://i.imgur.com/S7RYfyh.png

    My expectation with this is that the for loop will run, ends and then the empty condition-event will execute. Turns out that is not the case. It runs BEFORE the for loop ends.

    Fine. So I do this:

    https://i.imgur.com/lbVxbGA.png

    Guess what, that code that checks if loopindex >= currentWaveEnemyCount? That doesn't run at all. So I put a "DebugText > Set Text to loopindex" inside the for loop to see what that brings. It is 0.

    The weird thing is, in the game, the enemies spawn with 1 second wait time apart just like the for loop code says. But for some odd reason, loopindex is 0.

    What gives?

    Another similar thing. I have a repeat every X seconds event that looks like this:

    https://i.imgur.com/07kUpz4.png

    At first, the event didn't have so many "Call IncrementWaveCount" or "Add 1 to currentWaveID". It was only the highlighted part at the top. I thought that the repeat would happen, passes by all conditions firing the correct one and then firing the bottom highlighted section.

    That doesn't happen. It loops 3 times without executing ANY of the conditions that check IDs and then on ID = 5 it works.

    So I thought I'd force it to work, so I put at each condition the increment call + add 1 and then I removed the bottom highlighted part. I also included an empty event to run after the forloop to stop loop

    Again, with the weirdness, the ID was incremented to 7 in an instant and ALL conditions were run.

  • You do not have permission to view this post

  • You do not have permission to view this post

  • Let's see if I understand you correctly. For example, you have a family that has enemy1, enemy2 and enemy3 types and called Enemies. Each of them has multiple instances.

    If you want enemy1 to do 2 damage while enemy2 does 5 damage.

    You only need to give the family an instance variable called "damage" for example. Then when a family member is firing, you use "Enemies.damage" in the damage amount. This will reference the exact instance of the exact type that did the damage.

    Same thing for HP. If you want them to have specific HP amounts, you'd give them a family instance variable called "hp" for example and then when they receive damage. You'd reference the family instance variable "Enemies.hp"

    Note however, which instance and which type is affected by this depends on how you're picking the object.

    For example if player collides with instance 3 of type enemy3. And your event looks like this:

    Player Collides with Enemies > Enemies.hp - player.damage.

    This picks the specific enemy that collided with the player and uses its own hp value and take damage out of it.

    That said, I could have misunderstood what you said and this may not be helpful. In this case, I apologize and please disregard this response.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • for x random(Sprite.X-Sprite.Width/2,Sprite.X+Sprite.Width/2)

    for y random(Sprite.Y-Sprite.Height/2,Sprite.Y+Sprite.Height/2)

    Wow, that was super easy. I don't know why I didn't think of that. Thank you very much. For some odd reason, I thought it would be something built in and had a brain freeze when I didn't see it as a premade thing.

  • Hello everyone,

    Not sure if this is possible or will be complicated. Basically, I have a regular square sprite.

    Nothing fancy, just a square colored blue for example.

    What I want to do is spawn an object at a random spot on that square. So if the square is 16x16, I'd be able to pick (0, 16), (1, 3), (4, 8), etc... points on that sprite and spawn an object there. I don't need to pick a specific spot, just a random one that is within the surface area of the sprite.

    Is that doable? If so, how?

  • You run through the functions and end up with 'if EnemyBasicMelee' then do an attack. You could just use this as the only condition and scrap the other functions.

    Sure that might work, but let's say you're doing this for 20 enemies. Some of these are slightly similar but different some ways (i.e. heavy vs light melee) it would quickly get messy. But maybe I am wrong, I'll try it out.

    Also one other thing to note you don't need to forward a UID anymore, you can use the 'copy picked' option in the function, if you tick this then it keeps the picked Enemies instance. Also I disagree about the 'messy' code, I would keep it all in one function when it's simple enough.

    edit :

    And to fix this original problem you need to send through the variable in the second function, so instead of Enemies.UID it is enemyUID the variable.

    Amazing catch, thank you very much. That definitely fixed the issue!

    I didn't know about Copy Picked. I just read about it and that is an amazing feature, wish I learned about it earlier. This simplifies my setup quite a bit

  • The middle function doesn't pick any Enemies instances

    That is correct, its job is to decide what kind of enemy we are referencing (melee, ranged, kamikaze, etc...) and forward the UID to the function that does the attack.

    and i'm not sure the need for it or what's happening in there. You need 3 functions to run an attack? It's a bit convoluted just put it in one function then nothing can go wrong.

    I am trying to divide the "code" so it isn't all in one function so it is easier to maintain. Having one massive function that checks every single enemy type + their attack pattern is going to be super messy. Not to mention bosses.

    The way it is setup, I have the common stuff in one event page. This one event page forwards to 5 separate pages that belong to each type. Each type then picks the specific sub type to do the action.

  • Hello everyone,

    I am working on a prototype that has a family called "Enemies". This family has about 5 different enemy types.

    The enemies have AI but given the common nature of their behaviors I am using families to filter which ones to apply different AI state actions to.

    The below events pick enemies based on who finishes the attack animation:

    https://i.imgur.com/1eJNKM3.png[/img]

    Note I pass the UID of the enemy to filter with it.

    Next I start classifying enemies based on what type they are and forward the UID to the final attack action function:

    https://i.imgur.com/2IY1DMJ.png[/img]

    Finally, I pick the enemy based on the UID passed and do the attack action (namely spawning an effect):

    https://i.imgur.com/wwYfed7.png[/img]

    The issue I am encountering is that despite picking the specific enemy using its UID, the effects spawn at a single enemy's location instead of at each of the enemies.

    Moreover, when I change the first screenshot's condition "On Attack Animation Finished" to include "For Each Enemies" to make sure that the event loops over every single enemy instead of one only, it doesn't fix the issue. The same issue happens.

    Does anyone have any idea what is going on here?

  • You do not have permission to view this post

  • I haven't played Jump King but I am guessing from videos, you hold some kind of key to jump and based on how long you hold, the jump height changes?

    If that is the case, something similar I did was add an instance variable called "jumpLength" (number). Then in the event sheet I would do something like:

    Key is down (Space) -> Add to jumpLength variable (dt).

    Then in your jump logic, simply add jumpLength. You can increase how high the jump is by multiplying a constant instead of just adding "dt" so something like "5 * dt" for example.

    Note that it would be a good idea to have another variable called "maxJumpLength" to limit how high the jump can be.

Vallar's avatar

Vallar

Member since 24 Mar, 2014

None one is following Vallar yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies