Ruskul's Recent Forum Activity

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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

  • I suppose I could use the z value on my colliders. Opacity is set to 0, since they are non-rendered, and the model is a separate sprite.

    I like the simplicity of version 2. Its a nice way to avoid the event sheet loops. Very nice :D

    I, uh, ... forgot that Overboy has a utility for this. And I have it in my project lol. That solves the issue for me, though in projects I intend to share I keep vanilla c3 only, so this method is good to know of. Thank you.

    I swear R0J0hound , you are an absolute treasure trove of knowledge when it comes to elegantly phrasing events; A true Shakespeare of construct.

    10 years ago, you showed me how to get a vector projection. I didn't even know what sin and cos were at the time, or how to ask about the math... , but you were a real help. Thanks for taking the time to share what you know. It means a lot.

  • I would like to add some utilities that I would use on objects. I understand I can make this as a behavior, or create a plugin that handles these things, but, if possible, I would prefer to simply create a few additional common aces.

    Is it possible to do this with the sdk?

  • Currently...

    I simply have a variable on FamilyA, isFamilyB.

    Then if I am doing stuff with A and need to pass off to familyB, I have to do a for each FamilyA where I take the current the object's UID and then pick familyB by uid.

    It works, but I hate it because its a forloop and I can't afford unnecessary loops in the event sheet.

    From an organizational standpoint, in makes sense to keep this functionality in separate families, as they are not mutually inclusive in all circumstances. But Family B will always be indicative of Family A.

    Is this the way, or are their better methods, either from an organization perspective or some other trick to transfre the current SOL from object type to object type.

Ruskul's avatar

Ruskul

Member since 23 Nov, 2013

Twitter
Ruskul has 2 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x6
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

17/44
How to earn trophies