nimos100's Forum Posts

  • You can make a global variable called "Last_generated_number" and each time you generate a number you store it here.

    Then you can do a check:

    While

    random(number) = Last_generated_number

    Then as long the random(number) = Last_generated_number it will make a new roll.

    Then when its not Equal to the "last_generated_number" it will continue and you can use it. Then you store the new number in the "last_generated_number" variable, so it will be used for the check next time.

    If you dont used negative numbers. You can just put "Last_generated_number" to -1 as default from the beginning, so it will never match the first generated number.

  • This is a guess as im not sure how or when you get the error message :) but maybe you are trying to store more data in the variable than possible.

  • Btw im using IE 9

  • Here is an image, with how it works in both internet explorer and chrome.

    In chrome after i select item 2 in the list it changes to item 2 and item 3 with no problems. But in internet explorer it doesnt. However in some cases it might select the item if i try to select another, like in the screenshot where i select item 3 even after it fails selecting item 2. However other tests i made it wont change at all. But if no one else seems to be having this problem, its probably just my internet explorer that is screwed up somehow.

    <img src="http://i48.tinypic.com/24ywwvm.jpg" border="0" />

  • I just change the item in the list object. There are no events or anything added to the project, its a completely empty layout with a list object that have the 3 default added items, that are there when its created. And i just try to select for instant item 2, but it wont change it.

  • Link to .capx file (required!):

    http://

    Im not sure if its a bug with construct 2 or not. But if someone can try it and see if they get same result it would be great. It seems to only happen in internet explorer for me.

    Steps to reproduce:

    1. Create a new project and add a list. just using the default settings.

    2. Change the item in the list.

    3.

    Observed result:

    Wont always change item.

    Expected result:

    That it change item.

    Browsers affected:

    Chrome: no

    Firefox: Dont know

    Internet Explorer: yes

    Operating system & service pack:

    Windows 7 Service pack 1

    Construct 2 version:

    r124

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

  • 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

  • Try Construct 3

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

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