nimos100's Recent Forum Activity

  • Yeah i think you are right. Just have to find a way to get around it, i guess.

    It would be a nice update to the path finding, if it marked cells not reachable as blokced, If there were no way to get to them. Or it checked all cells around and object before reaching the conclusion that path is not found.

    But thanks anyway :)

  • Hi Vee

    I have tried changing the cell size to different sizes, even as low as 4 pixel. But still gets the same results.

    In the manual it says the following:

    "If you ask the pathfinding behavior to pathfind to a destination inside an obstacle, it will simply find the nearest clear cell and pathfind to there instead."

    Which is the case in my test, as the green square is a solid. The red outline is just a sprite with no events or behaviours attached.

    If you look at screenshot 1, there are lots of free cells on both the top and bottom of the green square. Just as there are in the two other screenshots.

    One thing i have been wondering about is the "..find the nearest clear cell.." thing and since the starting position of the blue square in all test are the one shown in screenshot 1, that when it try to find the closest free cell it tries to choose one inside the enclosed area, as they are is closer to the blue square starting position. But then if i compare the placement in screenshot 2, where the green square is actually closer to the blue squares starting position it doesnt really make sense as its actually closer.

    I have added the capx here: Path finding test

  • Hi I made a post regarding a possible bug with path finding, but it got closed due to this:

    Reply:

    "Closing, as this is by design. The Pathfinding behavior will report 'path not found' if you send it in to an enclosed area (as in, an open space surrounded by obstacles). If you tell it to move on top of an obstacle, it will find the nearest open space and move there instead. That's all that is happening here."

    Since i cant response to it. And still dont get why it shouldnt work and as im pretty new to the path finding behaviour my self, maybe someone here can explain why it doesnt work.

    I have added some screenshot further down, that might make it easier to understand what i mean.

    What i dont understand, is what is meant with enclosed area, as it is not send in there? If i place the green box about 20 pixel or so further down or up the screen from the red outline, so it still blocks the opening it works fine, and the path finding will find a path to the side of green square thats pointing away from the enclosed area.

    But if i move it into the red outline it wont, even though the side of the green square pointing away from the enclosed area, is just as available as in the other tests.

    This one doesnt work.

    <img src="http://imageshack.us/a/img268/9292/image1vuye.jpg" border="0" />

    This works fine.

    <img src="http://img829.imageshack.us/img829/6762/image2jzc.jpg" border="0" />

    This works fine

    <img src="http://img401.imageshack.us/img401/3285/image3qi.jpg" border="0" />

    I dont really see what the big difference is between these cases when it comes to finding a path, can anyone explain why placing the green square such a short distance from each other, can make such a big difference?

    It will be a great help as its really screwing up my game :(

  • Hi im actually working on or just finished something similar to what you want. <img src="smileys/smiley4.gif" border="0" align="middle" /> So maybe my solution can help you.

    My initial idea was to use arrays to store whatever order each unit should do, but i find them very confusing in construct 2. And ran into some problems with them doing weird things, so dropped using them.

    Instead i made a list object for each unit as they are created and added a "Unit_ID" variable that holds the UID of the unit it is linked to. This list can be seen as a queue of orders that the unit will perform.

    So in your case it could be.

    Miner.cargo_hold = 0 then Add to list "Go mine".

    Miner.cargo_hold = 100 then Add to list "Return to base".

    And so on.

    Then you can make an event that check each miners order list.

    So if miner1 have "Go mine" as the first item in the list. You can make an event that triggers if a unit have that job.

    In my game two units cant work on the same thing at the time, so I added a function that make the units enter a "wait for job" state. It then goes through each unit one after another, to see if there are anything that needs to be done. And if its the case, that "job" gets locked to that unit.

    Another way that can be useful as well, if you dont want to work with lists, is to add an Text variable to your miners called "Order" or whatever. And as default you set it to "None", if we assume that these miners uses fuel as well. An example could be:

    Event 1:

    Miner.order = "None" then Set Miner.order = "Go mine"

    Miner.fuel = 100

    Event 2:

    Miner.order = "Go mine" then Miner fly nearest mining place.

    etc etc.

    Doing it by adding or updating the miners order each time they reach there goal. Will make it easier to keep track off them i think. Also it will make it easier to check you program if you can show the order of each unit as you test your program.

    Assuming that suddenly one of your miners go crazy while testing, and you keep track of what order it have, will make it a lot easier to see where things might go wrong. For instant if a miner have order "Go mine", when it starts to act crazy. You can easily find the place in your program where it receive that order.

    Also its a good idea to use "For each (ordered)" and then in expression add the <object>.UID, since UID of objects cant be the same, it will go through all objects of that type, one after another and will only pick one at the time.

  • Would like to see shadows. And an update i think is really needed is to the containers. So when you build them there should be an option to maintain the position of each object in relationship to each other. So you dont have to set there position when they are created. It takes such a long time and is very boring <img src="smileys/smiley12.gif" border="0" align="middle" />

  • Cant you just add a variable Clickable to the buttons, and if its false you cant and if they are true then click?

    "The image point is set to 0. Maybe because he doesn't know WHERE to spawn the objects."

    It should spawn at the origin of the object spawning it, if nothing is changed. You sure it spawns on the correct layer, and that its on top of the layer?

  • There are several ways you can do it.

    1. Which i think is the best way is to destroy the buttons when you are not using them. And create them when needed. Add them in a container if possible, even though having to align them after create is a bit time consuming. That way you know they are not active when not needed.

    2. You can move the buttons off screen, so if button not needed set position to -1000,-1000 and when needed you just set them back to there original placement. You can add two variables, "Original_X" and "Original_Y" and set these values in the layout before hand.

    However would recommend the first option :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My best guess to why your booleans are giving you problems is most likely because you pick objects wrong, so you end up setting booleans for objects that shouldnt.

    The benefit of using variables linked to objects, is that it helps make your project a lot easier to work with, as you know that variable linked to those objects wont interfere with anything else, and can only only trigger for those objects. Also they get reset to default values whenever a new object is created, so you dont have to think about if a global variable is at the correct setting for that object. But changing it, might screw up things for other objects. So quickly you will start to loose control. However if you dont like using them i guess there shouldnt be any problem in just using globals, if you can keep an track of them.<img src="smileys/smiley1.gif" border="0" align="middle">

    Regarding the size of the ghost. Your ghost was 19x19 and had a cell size of 40. Which means that your map (layout) is divide into 40x40 squares, and each of these will be checked for whether they are "clear" for objects moving through them. If a solid object like your walls are touching one of these cells, it will be flagged as "not clear" and object can move that way.

    So if you have a map(layout) which is 100x100 pixel and make a cell size of 100, then you would only have 1 cell.If you then add a solid object with a size of 10x10 some where, it will mark the whole map as "not clear". as its covering that 1 cell.

    But if you decrease the cell size to 1 you would suddenly have 10000 cells to check for being overlapped or not. If you then add your solid object, it would only cover 10x10 (100) pixel of the 10000 pixels. Making it possible for objects to move around the map.

    However its not a good idea to set cell size to 1, its just for the example, as your computer would have to make way to many calculations when finding paths.

    A good rule of thumb is to use the largest cell size that you can get away with.

    You can read more about it in the manual:

    Path finding

  • Link to .capx file (required!):

    dropbox.com/s/d4bghjlk9rmt9t7/Path_finding_test.capx

    Steps to reproduce:

    1. Test 1: Press "1" to make the green square follow the mouse, move it over the opening so it covers the red square and left click to place it.Press the button "Find path to green".

    2. Test 2: Following the same steps as in Test 1, but this time place the green square so it covers about half of the red square in the opening. And press the button "Find path to green"

    Observed result:

    Test 1: it will return "Path not found".

    Test 2: Will move to the green square.

    Expected result:

    Test 1: Expected that the blue square would move to the green square.

    Test 2: Expected that the blue square would move to the green square.

    Browsers affected:

    Chrome: yes

    Firefox: Dont know

    Internet Explorer: yes

    Operating system & service pack:

    Windows 7 with service pack 1

    Construct 2 version:

    r122 beta release. Also tested in r123 beta release which gives same results.

  • Think you can make all the objects on the layouts global, that will not destroy them on "end of layout". However havent tried it a lot. So not sure if it can do what you need.

  • Not sure if this helps or not.

    But personally i think its a good idea in the event "on start of layout" to destroy all objects that you are not using. Just to make sure that you dont have rogue objects screwing things up suddenly. So if you have a main layer where the game take place, simply pick all <objects> and destroy them. And then add what you need with the system -> create object afterwards, if you need objects to be on the screen at the beginning of the game. The one object that is not moving might be due to it being a "rogue" object.

    "How can I set certain nemos to be placed and move in certain areas"

    Not sure if it fits your design, but a way you could do it, is simply to add a tracing sprite of each area, and setup the collision points so it fits it.

    Then add an ID variable to the Nemo object, called "Area_ID". As you create you Nemo objects, you add the UID of the tracing sprite to "Area_ID".

    After that you can add an event, that if Nemo objects with Area_ID = <Tracing UID> is not overlapping Tracing sprite then change direction, or what they have to do.

    And how can I after they are destroyed to spawn at the correct spawner object?

    If the above works for you design, you can simply let the Tracing sprite spawn the Nemos, and since its already picked if it spawns the Nemos, you can very easily in the same event set the "Area_ID" of the nemos to that tracing sprite.

    Hope it helps or at least give you some ideas :)

  • Hi Waffle

    I have looked at your capx. And if i have understood you correct, you want the Ghost to trace a route for the player to the correct exit?

    If thats the case there are some problems with your program.

    1. I dont think that "Find path" works in the "on start up event".

    So instead you can add a boolean variable to the ghost and call it "Tracing" or whatever and set it to false by default.

    Then add an event that if "Tracing = false" Then "Set Tracing = true" and "Find path(X,Y). Then if you want it to run again you can simply move its to the start position and set the "Tracing" variable back to false.

    2. The size of the ghost is way to big for your maze. The maximum size that you can use is 9, for both width and heigth and the cell size.

    An idea that might make it a bit easier, is to use a sprite instead of X,Y values when you use "find path", So if you make a sprite called "Ghost_target" for instant and then in the find path, you can simply write "Find path("Ghost_target.X, Ghost_target.Y")" then you can move it around on the layout or runtime without having to update your X,Y values each time.

nimos100's avatar

nimos100

Member since 23 Sep, 2012

None one is following nimos100 yet!

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies