Vallar's Forum Posts

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

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

  • Probably 1 because 2 means you load all the graphics in one object which is bad for image memory usage. To store the loot though like in an inventory I would use an array.

    I didn't think of that, thank you very much for the heads up on this!

    If I were given a case like this, I would separate the card objects as icon from the real objects themselves (weapons, potions, armor, etc.). For card objects, I will just create one sprite with icon images for all the real objects. I prefer playing with JSON for data processing which contains all the attributes of the real objects that are used as references for game logic (Data Driven).

    I am familiar a bit with Data Driven Design. The question here is, how do you link the graphical object with the specific section of JSON that relates to it? You'll need some reference somewhere from/to either. Or is that what the animation name to ID for? So you'll have say "Sword of Darkness +3" in the JSON with "id" : 4 and then name the animation to "4" and reference the JSON data from there?

    If that is the case, how do you make sure that if for any reason you change a reference you update the corresponding ones?

  • Are you sure the origin of the two animations is the same?

  • Hello everyone,

    I am working on a prototype of an idea where items in the game act as cards. Imagine a regular RPG (for the sake of explanation) where each sword, bow, staff, armor, potion, etc... is just a card similar to card games.

    Now the conundrum I am encountering is how to effectively handle loot without too much hassle (if that is even possible).

    Right now, I am thinking of two ways:

    1- Each item is a separate sprite that belongs to a type family. So MeleeWeapons family in C3 would contain swords and daggers for example while RangedWeapons would contain bows and crossbows. I'd manually apply a sprite appropriate for the item and add family variables such as name, damage, range, durability and skill.

    This would require that when, say, I loot a chest, I would have to generate a random number from 0 to how many types of items I have in the game. Each type has a number ID and that random number decides the family I'll create an item from. Then another random number from 0 to max family member size to choose which item in the family to specifically create for the player.

    2- I create a XML/JSON file with all the items. I load up the JSON/XML file at the start. I create a single sprite called "LootItem" for example that spawns when the player loots the chest from the first example. Then at that moment, I randomly pick an ID from the XML/JSON file instead of the above method. The issue here will be that I need a specific PNG for each item and to my knowledge, I can't reference "X.png" in the JSON to load it in a sprite, I'd have to apply it as an animation or frame and know these animation names/frame number by heart to reference in the code. Not to mention the sprite will need to cater to every possible item type's setup. A weapon may have damage and range but a potion won't need those things for example so it might get confusing as the game gets more complex.

    To me, the first solution is more work generally speaking than the second but it is far easier to maintain. If an item changes I just change the specific sprite for it. The ID ranges would require me to remember to change if let's say a family of items became 5 instead of 6.

    The second method seems to save time at first but the issue with loading the art file would make it a complete mess if I decide to use "X.png" for weaponA instead of WeaponB or if any of the IDs changed for any reason. Not to mention the whole mess from dealing with different types of items that do different things, if not for anything, then when I display a tooltip so I don't display "damage: 5" for an HP potion. I am also not a fan of how you extract information from JSON/XML it just feels off in the events sheet.

    What do you folks think? Any feedback/ideas/suggestions are welcome.

    Note I don't want to jump into coding for this setup.