farflamex's Forum Posts

  • Thanks, that's a good idea to use the browser log. Not sure why I didn't think of that considering that I've just finished playing around with a large PHP project and was using it all the time.....

  • I'm having a problem trying to work out why an object isn't being picked. My code is picking all objects with a certain value and then picking again on another value, but it's not then picking correctly at the next piece of code. I'm sure I can work it out, but for future reference, when I'm looking at the debugger like this and the engine picks an object, is there a way to know which object is picked? All I can think of is to manually create a variable, load the object UID into the variable and then find the object manually in the debugger. Or am I missing it in the debugger info somewhere?

  • Oh my, I was about to post my code and as I was looking through it I noticed the problem.

    I had a loop called 'FLoop' but I was checking it with loopindex("Floop"). Yeah, they're not the same thing :p

    My bad, it's working now.... I think.

  • Even then, it feels completely broken to me. I'm running it step by step through the editor. Because I'm confused about which way it will load in the values, I'm having it load it both ways, into two variables, e.g loopindex,1 and 1, loopindex. Even though it runs 10 times, the values never change. The first seems to grab the value at 0,1 and then never change. This isn't right, because, if it's doing it 'correctly' (i.e the traditional way an array does things), then it would run across the values, e.g 442 then 532 then the word 'test', since I've added a new row to try to work out what's going on.

    The second value grabs 'DL', which is at 1,0. Again, this is 'right' on the first pass because I switched it over. But then it just stays the same, stuck on 'DL' for the rest of the loop. It should be running down the row, e.g DL, then DCL, then DCR, but it just doesn't move.

    I can't fathom this out at all, it seems completely broken or I'm doing something fundamentally wrong. It's odd because I've used arrays in dozens of languages, so I know how they work in my head. It's not just a case of C3 being backwards (which it probably isn't), but there must be something wrong in the debugger or in my code, because it's not giving any correct values out at all.

  • Mind you, it's still confusing and something seems to be wrong about the whole thing. For example, now that I've transposed it, yes, it looks in the debugger how it looked in the editor picture above... but now it says that it has 2 width and 11 height, even though the debugger window shows it as 11 width and 2 height....

    I think the only solution is to just run everything through the debugger and try every combination until it gets the right one...

  • Ahhh ok, well it's good to know that it wasn't just me being insane.

    And thanks, the transpose thing will help. At least I know what the array actually looks like now. Mind you, now I've transposed it, it's altered quite a bit, but hopefully if I can at least see how it's structured, that should line up with my code.

    I suppose the main point is, it looks like it looks in the debugger and not necessarily how it looks in the editor.

  • I already seem to have dyslexia when it comes to C3 arrays. I have no problem with them in other languages, but they just seem painful in C3. Anyway, I typed in my values into the array editor, made an array of the exact same dimensions and loaded them in with Ajax, i.e 'Load from JSON string, AJAX.LastData'. I don't know why, but the x and y seem mixed up. I'm sure that's not true as somebody would have noticed and fixed it by now. But here are the images of my array in the editor and then in the debugger.

    I assume I'm just misunderstanding something about the way they're displayed. It just gives me a headache because I have to follow it through, line by line trying to work out whether it's checking columns or rows....

  • Thanks, it was an error(s) on my part I think. Basically I ripped it up and tried again and it's fine now, so at least I was understanding the pathfinding correctly. Must've made one or more mistakes elsewhere.

    Just in case it's of some use to anybody (not very likely because this was very vague), I had two mazes and I was trying to get the sprites to work out which maze they were traversing by first of all checking which maze they were overlapping. But I 'think' that C3 doesn't count overlapping as being inside the coordinates of the object, rather than actually colliding with it. And since the 'empty' squares of the maze had collisions off and the sprites were standing on empty squares, I don't think it registers as overlapping.

  • My pathfinding is working correctly at first but after a few moves, it stops working. I have 4 sprites pathfinding their way around a little maze (a tilemap). Two of them never move and the other two move a few times and then stop forever.

    Checking in the debugger, of the two that have moved, one has 'Has Path' set to true, but isn't moving anyway. All of the others don't have a path. I'm not changing the tilemap at all, so it's not a case of obstacles changing. There are no other objects that might be blocking the paths and they have custom obstacles set (just the tilemap maze). They're moving with 'Move To' once the path is found, so that they move PacMan style (i.e along the grid).

    They're all the same sprite with the same settings (i.e the cell size is set to 20 for all of them and the tilemap is 32x32 blocks). They're not blocking each other since they're not set as obstacles.

    What else could be causing them not to move?

  • Woot, move-to works perfectly. I didn't need to tell it to move from tile to tile, just told it to move along the path and it goes along the squares rather than around the edges :)

  • I know this has been discussed a lot, but I haven't seen a full explanation.

    I've set up pathfinding in my tilemap maze and it can find it's way from a to b. Problem is, it clips the corners, virtually passing through some of the walls. I've tried every combination of cell size and cell border and it either doesn't move at all, or it moves and clips the corners.

    I've seen people point out that that's all the pathfinding is really meant to do, i.e find the path. But is there a way to get to precisely follow the contours and never clip the walls? Say I have 32x32 cells, the 'player' is a 32x32 square and the walls are exactly 32x32 walls .... so the corridors are only 32x32 wide..... is it possible for the pathfinding to find it's way pixel-perfect down those corridors?

    Alternatively, would I need to do a custom pathfinder? I have an array set to the exact same shape as the tilemap already, so maybe pathfinding through the array would work?

  • Got this working in the end. Definitely needs a copy of the values to use during the loop and the rest was just fiddling around with C3 arrays, which are super-fiddling imo :)

    soccerstar.org.uk/c3test/index.html

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks. I think the full equations are unnecessarily complex for my needs. I think my method has two main issues, firstly, I need to take a snapshot of the grid before any calculations and use those values, as suggested. Secondly, averaging out the squares is probably why it eventually locks up, because outer squares pass values back inwards as those inner squares start to empty out. So I think it ends up in a kind of equilibrium. So it probably needs to be weighted somehow so that the source doesn't empty to the level of the destination, so that it should keep 'flowing' in that direction. I'll play around with it, thanks for the ideas.

  • I don't think that's the issue with the edge squares, because with C3, if there is nothing on a condition, it just skips the condition. So my code first counts any squares which have a lower amount than 'this' square, then averages them out. That works the same on an edge square.

    But yes, it does look like it requires some kind of entire-map calculation and my method probably isn't going to work, even if I 'correct' it. I'll take a look at the ideas you suggested and some pre-existing code. Thanks.

  • I'm trying to simulate fluid / gas mechanics in an array. The centre of the array has a large value, topped up to max constantly and I want it to spread out from that point.

    My first attempt was to run through the array and on each square, test the 4 neighbouring squares to see if they're lower. If they are, the final value of the square + lower neighbours is averaged out, so e.g If this square has 1000 fluid, one neighbouring square has zero (others are higher so ignored), then this square and the lower neighbour now have 500 each.

    This sort of works and does have the advantage that the values 'flow' through the array and around objects. But it also has 2 problems.

    Firstly, if I just run through the array with a foreach, it goes top-to-bottom/left-to-right and there's an obvious bias in certain directions.

    Secondly, and more fatally, some of the outside edges never receive anything, even if I use standard values with lots of decimal places. They don't even receive a tiny fraction. So somewhere along the way, the math obviously balances out and the flow is no longer pushing 'forwards'.

    One solution that I can think of in my head is to even out every square that's connected, all at the same time. Problem is, working out which squares are connected would probably require some sort of searching algorithm and I don't know how that would work. Plus that would lose the 'flow' feel, which I like.

    Any ideas?