ZeldaVerde's Forum Posts

  • I mean, is there even a way? Doesn't seem like it, can't find it in the manual.

  • WAIT YOU CAN DO THAT??? OMG I WAS LISTENING FOR EVERY OBJECT CREATION EVER AND THEN TRYING TO FILTER IT.

    thanks man lol .___. I'm dumb

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you thank you dop2000!! You're always so helpful.

    However what I want is to translate an "On <family name> created" condition:

    I added an event listener for objects being created, and now have to check if they belong to that family.

    Or is there another way to translate that that you'd suggest?

    edit: also I just realized my approach doesn't even make sense because an object can be in many families. But still, how'd you go about that then?

  • You could do it using two families that have the same objects in them (for you to reference the correct uids) like so:

    shooter_team has LOS to shooter_team2(or whatever name)

    for each shooter team

    -----shooter_team.UId not equal to shooter_team2.UId --> team targets team 2

    -----(whatever whatever whatever conditions)

    (srry I don't know how to format it in a pretty way)

    maybe also try removing the for each, seems like it should work

    and also maybe you can just use the same family, cause I feel like objects won't detect LOS to themselves but I'm not sure

  • I've searched everywhere in the forum and documentation but can't find any mention on how to reference families in scripting. I'd like to know how to get the family name of an object I have a reference to, and how to reference a family for doing stuff.

    I SWEAR I RTFM

  • I don't know if I get exactly what you ask, but I've recently created a very modular system for something similar and I'm very proud of it.

    In my roguelike dungeon crawler, I've put every entity (as in the player, enemies, and even stuff like breakable pots and crates but that is irrelevant here) into an Entities family. Then, one of the variables for that is Target, which contains the UId of another entity this entity desires to attack. Then all the logic that controls the entities always uses the target variable to define what they are attacking, walking towards, or anything really. So all the enemies' Target is defaulted to the player's UId, but I can make any of them fight any of them if I really want to. AND THAT IS AWESOME!

    edit: oh and I forgot a very important bit: every weapon an entity can use shoots a projectile (even if it's melee, it's just a shorter ranged one), and that has a variable that contains the UId of entity who fired it. That way, damage is "signed", and can therefore only damage other entities. That logic also applies to "teams". All enmies, for example, also sign their damage as the "enemies" team, and then each weapon may define if it's bullet has friendly fire or not. If it has not, that will only damage entities on other teams. So enemies can even target and destroy crates on the layout if I include so in their AI.

    Man I love this system, hope it helps.

  • Thank youuuuuuuuuuuuuuu!!!

  • Update: Apparently .children() does not return an array as in a regular javascript array, that's all I know tho.

    Apparently, there are three types of arrays here:

    .The javascript arrays

    .The construct array plugin arrays

    .This weird kind I'm getting which seems to be the same kind of array you get by creating a json array in construct (which, fun fact, I've noticed starts with "c2Array: true")

    please help ><

    edit: also for some reason the .getAllInstances() method returns a regular JS array so I wonder what's the criteria

  • Dude you are amazing! Thanks again, but how do I make it so that when creating the object, it changes the tile, and when it is destroyed, it sets the available tile again?

    The way I'd do it is I'd make it check all available tiles (from checking all existing cannons) every time you want to spawn a new one. That way it'd account for new cannons being placed and old cannons being destroyed.

    edit: oh ok his answer is way better (:

    I don't know exactly what you're doing tho

  • So why does this:

    const ObjectA = runtime.objects.ObjectA.getFirstInstance();
    const ObjectChildren = ObjectA.children();
    for (let j = 0; j < ObjectChildren.length; j++) {
     if (ObjectChildren[j].objectType.name === "ObjectB") {
     	ObjectChildren[j].destroy();
    	}
    }
    

    not destroy all children of "ObjectA" that are an "ObjectB"?

    the "ObjectChildren" array is empty and the for loop doesn't even run (because the array's length is 0)

  • Well that's about it, I just want to put a variable in the name of the function so it can be called dynamically, so how do I do that?

  • Those are the objects. The tilemap is supposed to only show where it overlaps the green frame, and the black square is supposed to show the green frame under the tilemap, hiding it. Currently, the green frame is set to destination atop, the tilemap is set to

    source out, and the black square is set to normal, and it is not working.

    Here is blend modes reference for help: construct-static.com/images/v1228/uploads/articleuploadobject/0/images/919/blend-modes.png

  • Maybe I misunderstand the problem, but try moving the mask object on top of the tilemap+fog. Disable blend modes on tilemaps, and set blend mode on the mask object (I don't remember exactly which one, just try them all). Make sure to enable "force own texture" in layer properties.

    Doesn't work, I'll post a better explanation shortly. Thanks for trying to help tho.

  • I'm making a minimap for my game. There is a minimap frame object in my minimap layer, as well as a minimap tilemap that has the "image" of the map, and a minimap fog object that hides parts of the map that haven't been visited yet. I set the tilemap to source atop so I can scroll it around and it only shows inside the minimap in the UI. Now I want the fog object to hide the tilemap, but if I use, say, destination out, it also hides the minimap frame. Any solutions?

    Tagged:

  • > Hmm I see the issue with that. But realistically I'd still want the z-order to be somewhat retained in the sense of something being above or below an object. If all the objects in the hierarchy are then, z-order wise, right next to each other that's ok but I think they should be in the right order, so that a sprite that is above another sprite in the template is also above the other sprite in the replica.

    I need to check that then, because the relative z ordering in a hierarchy should be kept.

    Doesn't happen to me