nimos100's Forum Posts

  • [quote:l51e2o7m]It chooses the empty cell closest to the destination. It's not going to use A* to find which empty cell is closest to the player because then it would have to pathfind to every cell on the map and that would take forever. And even that would be no use because the cell right next to the player would be the nearest.

    Agree with what you are saying and it might be a huge flaw in the behavior that in the end breaks it. Because if it just picks the nearest random cell to where its trying to go, there are no certainty that it will work and it will be completely random when it does and doesn't. However this is what my tests pretty much shows, but this also means that the behavior is so broken that it need to be fixed as its simply not working.

    From testing it seems that the pathfinding will always go to the cell below the cell being blocked. Which explain why it doesn't work in screenshot 1

    Rough distance check.

    However this kind of falls apart.

    As then this one should fail as well, but it doesn't. It actually moves to the top. And if I block all surrounding cells and just leave top open it works.

    However if I do the same but with the side it doesn't work.

    So I added so I can see the actual collision cells and then align the sprites to exactly overlap the collision cells. Which improve the path finding a lot.

    And it will be able to find path to both top and side.

    But further testing seems to cause the same problem.

    As it can be seen the tile right of the green tile is clearly not blocked, but still it ain't able to find a path.

    However moving the green tile 32 px up and then it works again.

    And again you are left exactly as the initial problem.

    [quote:l51e2o7m]..It's not going to use A* to find which empty cell is closest to the player because then it would have to pathfind to every cell on the map and that would take forever.

    Not necessarily, it could work its way out from the initial target. And stop at the first cell it encounters that it can actually reach. It would require more path finding calculations. But if the alternative is that it doesn't work, then I would consider it a better solution.

    Further more it have already calculated the values for the fastest/effective path to the initial destination.

    This is a screenshot from another site about A*.

    If we assume that the cell I have marked blue is blocked. it could move to the cell indicated by the arrow, and still make use of all the "path cost" information. And it could do that for each surrounding cell. And move backwards based on either condition being the primary one. Either find the nearest tile to the initial goal, no matter how far away it is from the path finding unit.

    Which is what I use in my game:

    As seen the enemies surround the target.

    This could be extended, so it would also value the distance the enemy would have to travel, in comparison to how close the tile is to the original target.

    How it works in my game, is that if an enemy fails to find a path to a target, ill calculate a distance to each tile from the initial target and the one with the lowest value will be the new goal for the enemy, as I use an functionality to average the distance all tiles in the same range from the initial target will have the same distance. So all tiles that are 2 tiles from the initial target might have a value of 60 and those at 3 tiles away have a value of 90, which is because there are no difference in my game whether you move directional or horizontal/vertical. But could change it by adding in some weight to how far this goal is from the enemy start position as well.

  • [quote:2547yadq]I bet if you took away the purple squares and just told it to find a path to the nearest green, it would be trying to move to a square on the inside.

    Yeah that would work as well, but then I could also just remove all the solids and then it would be able to find a path to the blue square. I don't say that to provoke you , but merely point out the initial problem.

    In most games where you want to use path finding the path it finds are calculated in real time, so you as programmer will not know where blocks/units will be at a given time.

    If we imagine that the example above illustrate a base of some kind that the player have build to keep out zombies and all the green and purple squares are barricades or fences, it wouldn't work very well if the zombies aint able to attack the walls if they cant reach the player inside.

    So the real problem comes as you can place the units in design time and then test it, and everything seems to work. But then as you run the program suddenly the units are in such positions that it cant figure out how to do it, and then you will have a lot of problems trying to figure out why it doesn't work. And then you will end up with the same problem as I showed in the first screenshots.

    To me it seems like the pathfinding behavior might not be 100% correctly implemented and seems to lack some features that would make it very good.

    1. The path calculated shouldnt place the nearest empty cell the furthest away from the unit using the pathfinding behavior. Based on the A* algorithm it seems to be wrong, as the cost to move there would be higher than the tile nearest to the unit with pathfinding behavior. And the fact that the pathfinding unit cant even reach that tile, so makes little sense why it then marks this as being the cell to go to.

    2. There should be two different mode to the pathfinding behavior, "Tilemap" or "Standard". Where "Standard" would be roughly as it is now. The "Tilemap" mode would be used for turn based games. If you use tilemaps with pathfinding in a strategic game where units move one tile at the time. The pathfinding wont work correctly with directional movement as it will see tiles next to it as blocking the path.

    Instead it will calculate a path all around them.

    Other solution would be to do it so if directional movement is enabled it should be able to move directional near other units,

    3. There should be a trigger for Regenerated obstacle map, just as an "on path found" it could be "On obstacle map regenerated". For a lot of games this would be very useful, but in general it would be a good feature to be able to track when the obstacle map is generated.

    Looking at screenshot 3

    The logic nearest empty cell would be something like this, indicated with the green line and not the red line which is what it chooses:

  • Have really struggled with the pathfinding behavior and its giving me a lot of problems. So i decided to make a small example and hopefully someone can clarify or maybe it will help push for some improvement with this behavior. But i really don't understand what is going on in this example as it doesn't really act as it should according to the manual.

    Some basic info

    • All sprites are 32, 32 px using a cell size of 32 pixel with cell border - 1.
    • Red sprite have the pathfinding behavior.
    • Green and purple sprites have solid behavior.
    • Blue sprite is simply used as primary target for the red sprite.

    Code

    Screenshot 1

    The test

    The red square will try to find a path to the blue square, which will fail as it cant get there, as it fail it will then find a path to a Green sprite which is nearest to it self (The Red sprite).

    from the manual:

    [quote:1fpisgiz]Note it may be impossible to find a path, such as trying to navigate to a destination inside a ring of obstacles. In this case, On failed to find path will be triggered instead of On path found.

    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.

    So based on this it looks pretty straight forward, as i know that it will trigger "On failed to find path" and then ill tell it to go to the nearest green tile, which clearly ain't blocked. However in screenshot 1 if i press the button nothing happens.

    However if i switch a green square with a purple and press the button. It works fine as according to the manual. (Screenshot 2)

    Screenshot 2

    A third test i moved the red square down 96 pixel and left the purple "Barrier" where it was normally and pressed the button again. And it seems to work as well.

    Screenshot 3

    Screenshot 4

    I have also tried to make the pathfinding behavior using the standard 30 cell size. And then none of the examples work. So what exactly is going on with this behavior how are you suppose to work with it, when it seems so unstable that it will simply stop working based on where objects are placed in relations to each other, the cell sizes and so on?

    I really hope that this behavior can get an overhaul as its so essential for so many games, and if its not reliable troubleshooting problems with it will be near impossible.

  • Tactical combat update

    Having spend a lot of time trying to figure out how I wanted this to work. I decided to split the tactical combat system into a more board game type of combat system.

    So it now consist of several phases.

    1. Movement phase

    All units will move in this phase in turn based on there initiative. This is because it seems more logic that even though someone might be faster than someone else, they shouldn't be able to run across the map and kill someone before anyone else is able to move.

    2. Action phase

    In this phase all actions takes place, such as attacks, using abilities, casting spells and so on.

    Mainly I have been working on the movement AI of the enemy and at the same time made it a bit more tactical so it allow the player and enemy a like to use there units more strategic, in the sense that units will now block all tiles around them, which will allow the player to use there warriors to defend weaker characters by placing them in the path of enemies that would try to attack them.

    Example of the actually movement of enemies.

    However it is still very early in the process and at the moment enemies only have one tactic which is to go in close combat. But plan on adding several tactics, so some enemies will prefer defending weaker targets, enemies with range weapons will try to keep distance, enemies with stealth might prefer going for casters and so forth.

    I don't think it will be all that hard to implement these tactics due to the way that I have made the movement work, as it should work correctly as long as I pass a coordinate to where the enemy should move. The movement system as it is now does work with stacking of enemies, so even if I pass an invalid coordinate it will automatically find the closest free tile to that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:232ikl5k]

    I don't understand why you write that my player turns 60 times a second. It's rotating clockwise, from left to right, like a clock... Did I miss something?

    When I check the parameters changes with the debugger, I see that my variable "gravity_angle" is only changing when touching the other gravity zone, not before (my "Passerelle" event is useless).

    In the first highlighted area, Clementbox is overlapping Passerelle, it will run 60 times each second as long as this is true. And it will rotate Gravity_angle + 180 degree clockwise.

    In the next one you will again 60 times a sec, Set the angle of Clement to the angle of ClementBox.Angle.

    And then you set the Clementbox Platform angle of gravity to Gravity_angle degree.

    It seems to me that there are some conditions that might conflict with each other. But im not really sure, it just seems a bit weird to me.

  • Had the same problem with my buttons, which are basically the same as yours except I use an effect, but I fixed it like this:

    Cursor is over "Button"

    ----> Pick all "Buttons" : Disable Effect

    ----> Pick "Button" nearest to Mouse.AbsoluteX, Mouse.AbsoluteY : Enable Effect

    Cursor is NOT over "Button" : Disable Effect

    So what it does is, as you move the cursor over a button you start by removing all effects from any buttons, and then you apply the effect to the button nearest to the cursor.

  • Im currently working on the movement part of my tactical combat system and it works somewhat, however there are something that give me some problems, which is the path finding, im well aware of the limitation of this behavior, so I only use it to find the path, all movement are done manually. However when it find a path it seems to have some problems correctly updating the collision map.

    All tiles with red and white lines are part of the tilemap which have a solid behavior. So they are seen as collision tiles. So all enemies have the tile where they are standing on made as a collision tile. When they start moving I erase that tile and then calculate path to a player character. And when they are done moving I update the tilemap again and regenerate the obstacle map for the enemies.

    So an example where it works.

    In this case the enemy will correct move around the enemy standing on tile (4,12) when it tries to reach tile (3,12).

    For some reason this doesn't always work as in this example.

    Where the enemy is suppose to go to tile (27,25) and the tile at (26,24) is not a collision tile.

    However it choose to move on top of the enemy at tile (26,25). And I just cant figure out why it works in some cases and not in others.

    The manually movement will go from one path finding node to another, so if the path finding have plotted a wrong path then the manual movement will fail. But what I don't get is why doesn't It register this tile as being a collision tile, but in other cases it have no problem. The movement of the enemies are triggered when a path is found as recommended in the manual. If anyone have tried something similar or know what the problem can be I would appreciate any help.

    Here are some quick facts.

    1. Only 1 enemy moves at the time.

    2. Before an enemy starts moving the obstacle map is updated.

    3. After an enemy have moved the tilemap is updated.

  • [quote:1q14pw30]This is the game so it will be in many different browsers. Shouldn't Construct2 override arrow up at least it says like that in documentation.

    I cant find in the documentation where it says that? but i get your point. I dont know how you can do it, doesnt seem to be any setting for it from what i can see

  • Think you have a better chance of checking out with the browser you are using if it can be done there. I dont think it have anything to do with C2, otherwise you can use the nodeweb kit one.

  • [quote:2zgfr3l6]Could someone explain me why my ClémentBox is not rotating when it is overlapping my object Passerelle?

    Thank you in advance for any help you could give me.

    Are you certain that it doesn't rotate? it seems to be rotating Angle + 180 degree 60 times a second, so are you sure that it just doesn't rotate so fast that you think its not rotating, try to run it in the debugger and see if its angle changes there. Otherwise there must be some other code that mess with the rotation, that are not in the screenshot.

    Maybe its the angle one in the every ticks that screws it up, try to disable that. (The last line)

  • How do I calculate Position (X,Y) if I know the Angle and Distance ? I know it has something to do with sin and cos, but trigonometry was never one of my strong points

    What do you need it for? Was thinking that there might be an easier way, if people knew what you wanted to use it for,

  • I see, I unfortunately havent made any games or a lot in general with character animation in C2 so not really sure how people normally do it.

    Guess someone with some experience on this can probably help you better

  • Can you just make a third animation Run->Stop

    So when player release button you finish playing the run animation until frame 10, then when that is done you trigger the Run->stop animation and when that is done you play the idle one.

  • [quote:27dhbzm8]Any ideas to get this effect that is efficient and accurate would be welcome.

    Unfortunately I don't think I have any ideas you would like As I would suggest remaking the hair so they are made for fitting your head sprite better. Because it sounds like it would probably take longer time to create the code to fit all the hair parts, than to just recreate them.

  • [quote:tnpwypnk]Having said that, I believe, the error in my approach is the way I am comparing the Function parameters.

    Would be great if you can clarify on this part.... or correct my approach.

    Your approach and code is correct. Your problem is that you try to assign a string to a int variable. In your function you return "Even" or "Odd" but the result requires an integer. So if you change "result" to a string it should work.