Juryiel's Recent Forum Activity

  • Right, that's what I have now. I have two functions. One that creates an object, and one that initializes a layout (so that it will create the structures for objects created in the editor).

    But since I work on my game on and off taking month-long breaks, I'm worried it's going to bite me in the ass two months from now when I just casually create an object without my function and then wonder why stuff isn't working :) That's the downside of Construct. Usually if I do that in some programming environment it yells at me because I try to reference stuff that doesn't exist. Construct just keeps on going without any sort of feedback on what stupid thing it is that I'm trying to do. Hopefully that won't happen though.

    This S thing is pretty awesome though, I wish I knew more about it when I started, many of the things I already implemented would have been 100 times simpler with this.

  • Oh I see, thanks for explaining that. So it basically makes teh UID indexing and referencing the correct structure easier, but I still have to remember to create the data structure at runtime myself. Seems like it will do half of the functionality I want, which is better than none. I'll give it a shot.

  • Thanks for taking time to explain. I do understand how arrays and superstructures work in general. Sorry, my description is not quite clear for the array I had in mind. By 'variable' I meant a 'slot' for something like an effect, and by 'value' I meant different properties associated with that effect. What I meant was this example, where z is the UID, y is the 'slot' number, and x is the various properties of that slot like name and value (minus UID since I'm also storing it in the 'slot' since UID numbers assigned to objects are not under my control so I can't convert them to an index directly without using a Hash table)

    3D array that stores values in this form, with each of the matrices below being 2D slices of said array:

    ________________________________

    |UID1     Name1     Value1     |

    |UID1     Name2     Value1     |

    |UID1     Name3     Value1     |

    ________________________________

    ________________________________

    |UID2     Name1     Value1     |

    |UID2     Name2     Value1     |

    |UID2     Name3     Value1     |

    ________________________________

    Then I can just search the array by UID for the correct slice or use a hash table of UIDs and Array indices. Not as elegant as using a structure, clearly.

    The main issue is that every time an instance of an object is created at runtime, I have to manually do code to insert it into this array, and in addition, for objects created in the editor, I have to run a function that loops through those at the start of a layout and creates their array slices. Every time it is destroyed, I have to do code to remove it from the array. Oh the other hand, with a container as mentioned in my first post, since each object would have its own array that would be created and destroyed, that would be automatic.

    So I guess instead of asking "How" to do it with S (I'll figure that out) let me just ask, is it possible to take a family of objects, and every time I create an instance of one of the objects in that family either in the layout editor or at runtime, the appropriate data storage structure is created with S? (Note that just replacing families with S for everything is not ideal since I already have a ton of events that use family functionality that I'd rather not replace. However, putting all the objects in said family also in an S structure and doing it would be just fine).

  • Hmm I looked at the plugin and read the descriptions and a good part of the thread but I'm not sure how to do what I want with it. So I create the various sprite objects in a layout for storing objects, and put them in the correct family. Then in the game I spawn copies of them via Create Object.

    So at creation time I would also create an entry in S? Is that the basic idea? If it is, what does it buy me over just using a 3D array such that one index is the Object.UID, the second dimension is the variable name, and the third is the value?

  • Right, that's what I want in terms of functionality but instead of doing it for objects (e.g. a container for two objects) I wanted to do something where any object that belongs to a particular family has an array associated with it.

    The reason is that there will be, say 200 objects in that family (not instances but different objects, which will be sprites), that each need to be in a container with an array. Then throughout the game I will spawn instances of these sprite objects which would create an array to go with them.

    I can brute-force it so that every time I create one of the family objects I also create an array with the name of the object, and put them in a container, but I foresee issues in forgetting to do that and getting burried under a ton of arrays, but also more importantly, when I do the code, since each object will have a different array (as opposed to instances of the same array), I'll have to have a separate block of code to process each object's array.

    E.g.

    OBJ1 and OBJ2 are in a family called OBJFAM. ArrOBJ1 and ArrOBJ2 are their respective arrays in which they're in a container with

    When I spawn instances of OBJ1, an ArrOBJ1 would be created, and for OBJ2 an ArrOBJ2 would be created. But when I do the code, how could I then reference the correct array such that:

    Create some number of OBJ1 and OBJ2 instances

    Pick: OBJFAM instance by Some method

    Read and write to the array for the instance of OBJFAM picked.

    If I picked an instance of OBJ1 instead of an instance of OBJFAM, I would know that the code would always reference ArrOBJ1 and the container would pick the correct instance of ArrOBJ1 that went along with the correct instance of OBJ1 picked. But not sure how I would do that with picking the objects through their family association.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I have a family that contains a variety of sprites (like hundreds). I would like to store some values for each sprite in an array instead of using PVs. I was wondering if I could do something like when you use containers to create objects (in this case arrays) every time an instance of one of the sprites in the family is created or when a sprite is added to the family. The reason for this is because using PVs would be difficult since there will be a lot of values that need storing and would be tough to access one at a time through Family.Value('Var') statements and I'd rather use looping and such or checking specific indices.

  • I implemented this algorithm and it's actually quite good. Just to share, if your LOS detection is more spatially critical than temporally critical (e.g. if you care more about detecting tiny things inside the cone as opposed to detecting them if they enter the cone for tiny time intervals) you can do something like use a very small density of points while adding +/- noise proportional to the spacing between points. So instead of lined up points as in the picture, imagine a cone with garbled up uniformly distributed points that change frame by frame. Basically what you're doing is trading off temporal accuracy for spatial accuracy, instead of trading framerate performance (e.g. increasing the number of points checked) for spatial accuracy. Neato.

    I guess the reverse of that would be to increase the number of points but decrease the time interval at which you're checking (so every 5 frames).

    With some combination fo both you can get some really great performance for tons and tons of LOS objects.

  • I was wondering if it is possible to keep function parameters separated. I'm trying to call Function A from a couple of functions (say, Func B and Func C) which take different number or arguments, making it hard to use argument number for Function A. So like if Function B takes 2 arguments and Function C takes 3 arguments, if both of those can call Function A, then I'm not sure how I could make use of arguments in Function A. I can't just clear them because Functions B and C need their arguments after Function A is done.

    Is there a straightforward non-convoluted way to do this or is the best solution to use globals?

  • Thanks for the reply and information. Looks like there will be a solution in there somewhere that's ideal for me (I'm liking the cone of view code and can use it for a few other things in addition to LOS :) )

  • I'm trying to use the line of sight behavior without much luck. I have a bunch of instances of the same object (Enemy1), and they're all in a family (Targets). I'm doing a test whether the player is in the line of sight of a selected enemy. The enemy is picked through its family, and I can tell the picking works because other stuff happens to the enemy that doesn't include line of sight and that all works on the specific instance of Enemy I select. However, testing for line of sight seems to have no effect (the player is always in the line of sight regardless of the angle settings or distance settings, even angle 0). If I use the instance itself instead of the family it works but that won't work in the future where there will be enemies of different instances (e.g. Enemy2, Enemy3) etc, each in the family Targets.

    I read about some bugs with line of sight but it seemed like using families would make stuff work, but apparently not. I'm wondering if there's a known workaround or if I'm possibly doing something wrong.

    I could upload a cap if needed but I'd rather not do that to you guys because the cap is pretty complicated at this point and would probably be a pain to work through if the error is in some part of the cap that is not directly where the LOS check happens, and even that part is annoyingly complicated using arrays and indexing in an extremely convoluted way :P

  • Thanks, that worked. I haven't fully tested the cap to see if there are any issues with it but it does open and the family names do lack spaces :)

  • Sorry to take so long to test it, real life interfered :) However, I finally had a chance to test it but it didn't work. I got the error in the attached image. It made a file, but the file crashed when I loaded it in construct.

    <img src="http://dl.dropbox.com/u/30864403/error.png" border="0" />

Juryiel's avatar

Juryiel

Member since 30 Sep, 2010

None one is following Juryiel yet!

Trophy Case

  • 14-Year Club
  • Email Verified

Progress

15/44
How to earn trophies