Ruskul's Forum Posts

  • Just to make sure I am following this correctly,

    If I have a condition that narrows down famA to a few selected objects, I will still need to set pick1 to true, select all famA and famB, and then run the evaluate?

    Is there an assumption that famA count much be equal to famB count then?

    In the end, I may very well have 30 different object types in famA and only 10 in famB. For sure, I know that all famB are also famA, just not the other way around.

    But I'll also have cases where I don't know at all all but want to check. I am using families in this way like interfaces, such as iHaveHealth and iTakeDamage. Basically contracts and functionality that guarantee a particular object has a way to interface with basic data.

    A door, for example has health and can take damage, can take interactive commands, but it can't be confused and take other stat modifiers, etc...

  • In the second case, why did you have a pick2 variable when it isn't used? Is that for the reverse case?

    Secondly, I was wondering why you have a pick all for fam1 and fam2 in the condition for pick by evaluate. It seems in my test you don't need it.

    Last, how does this work? I don't understand the magic occurring in the pick by evaluate and how that transfers picking. Is there any limitation or caveat? How does it create an implicit foreach loop?

    Finally, If you use an else, it doesn't work as I would have expected, which I have noticed using pick by evaluate in the past. It will only activate else block if there are no picked instances in the prior. meaning until the picking condition is false for all instances, no instance shall be picked. But if you did a if compare variable condition, the else would work on other instances.

  • One way c# can hold your hand is access modifiers.

    Correctly used, nobody using the code can possibly misuse any variable or function. JS lets you seemingly use anything however you please. Don't want to be bothered with get/set functions? Just grab the variable and change it as you see fit. lol

    Its a real potential to shoot self in foot. Of course... c3 editor side does the same thing, since there is no way to protect variables or limit them to only some uses or scripts.

    Its a thing that doesn't make the language itself harder, just code one is working with.

  • So apart from distorts changing or adding collision poly points nothing is setup for modifying collision polys outside the editor.

    Maybe with JavaScript but you’d have to bypass the scripting api to get into the unsupported and undocumented innards that has a has the possibility of changing per release and breaking anything you do with it.

    I actually was hunting down what methods I might use. I see that you can use world info to get a poly's info, but so far I think the code for setting might be editor side.

    The mesh distort may be the way I go. I only need triangles and squares anyway.

  • Thank you everyone! I was trying to find it in a project setting or something, but sys action is great. Thanks !

  • Hey, I thought I saw a while back that there was going to be an added option for tweaking collision cell size in construct for optimizing collisions in specific cases.

    I might be misremembering, or perhaps it wasn't a setting that user was going to have access to it. Does anyone remember this conversation?

    It was based on a vampire survivor like game as the use case. Can't remember who all was involved and I can't seem to find it in google. :(

  • I don't think this is possible at all, but I make overlooking another way to solve my problem.

    Ultimately, I want a behavior to be able to alter the collision shape of the object. In editor, I would achieve this by changing frames in a sprite animation and having a different collision shape, but that can't be done from a behavior.

    In the end, I would prefer being able to create any arbitrary collision poly at runtime. But baring that, I still would like to be able to set collision polys.

    Tagged:

  • Welp, I didn't know about mixins. Anything I know about JS is merely because I program in c# and c++. Which means engine specific quirks or features are often the bane of my existence. I still forget whether I need == or === .

    Sigh... Maybe I should shutup and go learn this stuff.

  • RafaelMatos Thanks, I have his plugins and totally forgot he has some nice family pick sliding, etc... I was using his signals and data+ but forgot about the utilities. thanks for reminding me. Totally awesome tools.

  • Wait, I'm confused,

    I thought I got some error when I tried to treat a combo parameter with a switch.

    Thanks. I probably did something stupid that I can't figure out now, because the below works just fine.

  • Jase00 Here is a simple but dumb test to simply compare the "cost" of doing things a particular way. You can set the loopcount to whatever makes sense given your cpu.

    drive.google.com/file/d/1MAxcL6abf63VCZxdU4dBWbthdFzSFFIk/view

    In this, you can see routed functions have, of course, the highest overhead. I use tests like this to try and anticipate my "budget" for how many function calls I can have, if I am worried about performance. If I have a 100 objects and they each call 20 routed function calls. Who cares, no problem. But a 1000 calls is non-negligible in terms of performance impact over avoiding the routing.

    At the global scope, and not looped, I totally advocate using as many functions as you need to make life easy on yourself. But in performance critical areas, you have to avoid them. If you take a setup where you have routed dynamic functions invoking behaviors, and then you also use function maps for utilities that are sprinkled throughout, you can end up calling a mapped function 20 times as the result of one behavior. Multiple that by several other active behaviors, and per object, having a function call count of over 100 is not uncommon. That makes such object types crucial to either keep counts low, or... go the sdk route for their logic. Utility functions go into a plugin, and behavior logic can either get expanded into conditional tree event sheets, or a behavior sdk/js scripts.

  • Hey,

    I notice many vanilla behaviors have an action with an incoming parameter where a switch statement is used. Since you can't see the editor side aspects, I can't figure out how to use a combo type parameter with a switch;

    In c2, the parameters were numbers. I tried changing the json file to return a number, but that fails. Idk, looking for an example if anyone has one.

    What I want is: DoSomeAction(Choice, num){switch(choice)}

    Where in the editor, Choice is a drop down of options I have defined.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey all,

    I noticed from looking at the vanilla behaviors that in each place world info is used, the following line appears.

    	const wi = this.GetWorldInfo();
    

    Does that reference go bad any time there is a change, or can I add a const reference to it along with property declaration and use it thereafter anywhere I want in the behavior?

    If I can, why do the vanilla behaviors declare it it every function where they need it?

    TLDR: Why do built in behaviors call GetWorldInfo in multiple places instead of just once?

  • Jase00 I like containers, but how do you use them? I mean to say, how do you afford to not have everything in families?

    Many times I want to drop things in containers, but then you lose the benefits of a family.

    Common problems for me would be something like, All entities need collision handling so they go in a family. Then I can put particular entityA with the appropriate view model in a container, but all the big logic is in the family and has no access to that relationship. Then I realize I need a family for the view models because they all need to handle animations and frame settings and effects, and now my container is broken. I haven't checked if hierarchies can side step the picking problem, as so far I have only used them for compound environments or view models.

    ---

    As far as function overhead goes, it really isn't a big deal in 90% of cases. A simple test where you compare setting a variable in a function compared to doing the same outside of one gives you the basic overhead difference. Adding parameters increases the overhead as well. Again, not a big deal if you wrap 10 events in a function, as the per event cost decreases, but loops obviously multiple this cost.

    Again, probably not a reasonable concern for most projects.

    But if you structure a project to have everything in functions, and have a lot of needed utility functions for basic stuff (like vector math or other stuff), you pay dearly for it. Which again is tolerable in alot of projects. If I recreated Nes mario3, with copious functions and custom actions, down to simulating specific nes style subpixel movement and screenline rendering, I would still be cruising at a perfectly comfortable performance with room to run the game multiple times over and tipple the on screen badguy count.

    So like Ashley said, it isn't actually a big deal as most projects have other limitations long before function overhead is a concern, and the only improvement that could happen to functions that I can figure, is that we could have a special type that inlines it's contents at runtime (basically copy pasting its contents). That improvement would be useful for utility functions (like dot product, or add score), but it wouldn't work for dynamically routed functions- meaning half of my function calls still wouldn't benefit. You could think of inline functions as simply as putting a CONST place holder for a specific set of subevents that get placed there instead of a function call when you run the project.

    Since I rely on alot of trig functions that aren't included in c3 math expressions, these functions get called thousands of times per tick. The overhead of the function call itself, typically with a minimum of 4 parameters, ends up being more costly than all the sqrts being calculated. Moving these utilities to a plugin/behavior improves performance by more than 7x in that category; Which is alot in the end, but only because my project spends a huge amount of cpu on 3 things: 1. collisions, 2. function wrapped math, 3. function driven dynamic routing for modular behavior.

    Since a good 20% of my performance is based on shoving numbers around, taking it out of functions saved me around 17% cpu time, which is definitely worth it, for me, but only because I am trying to really push the object count.

    I've done other dumb tests for things like character input buffers - like if I store most data for an instance in an array, I simplify my event sheet and logic, but I have to use foreach loops to iterate the data. If I manually go over instance variables, I can save maybe 50% the processing time, but as this accounts for a much smaller percentage of overall performance, do I care? Well, unfortunately yes, but only because I am literally trying to see just how many thousands of complex entities I can have. But, so far those are all dumb entities. Adding in ai that requires basic information about its surroundings will quickly ellipse the performance gained by avoiding an array. Pretty soon that 2.5 overall performance increase becomes 0.025, and you wasted alot of time being an idiot about performance that didn't matter (this is me 90% of the time).

    TLDR The only issue I have had with function overhead is while trying to simulate dozens of characters with 100s of bullets all needing to calculate vector normals and projections, all looping 1000s of times over small functions that could be inlined.

  • This is one of the cases why I really dislike working with data structures in eventsheet context. Overboys addon does solve this exactly how I would envision it should be solved, like instance variables being able to hold arrays/json/data. But I'm at the point where I'm very comfortable in js so I'd just subclass the instance, give it a this.array and some methods to handle the data and call it a day. (If I ever manage to push out my current game, my next game will probably be 95% js)

    Tbh, I need to learn to do this. Ashley told me about subclassing and I was like ermergosh. The problem is that, if I wanted to use that feature, I would need to move more into JS, while the behaviors let me still use the event sheet. I'm not totally opposed, just as I mentioned, a huge appeal for me is the event sheet. Also, there is the overhead of becoming actually competent at js. I stutter and stumble, and typescript helps, but I've been using c# too long and have always disliked js. A total me problem.

    I have a hunch I am going to "compromise" on this project by going from chaos and pandemonium to stark and minimalist conflict, which imo fits the games style better anyway which is why it isn't really a "compromise" at all and a new "design decision", or at least, thats what I tell myself. lol.