Pakost's Forum Posts

  • Yeah, that was my first thought too, storing coordinates. I was hoping, there was a better solution tho. As i see it, a Recalculate Path action for the pathfinder behavior would be a nice addition.

    I believe there should be a way to determine where is the last node of a path, giving you the destination coordinates.

  • Hi guys

    I'm making a RTS like game and as any such game I plan to have units walking here and there. The problem is when I place another building, and regenerate obstacle maps, those units that are on their way needs to recalculate the path based on the new grid, right? But i don't have a clue where they are going... Is there a way to learn their destination so i can recalculate the path? I hope i will not have to store the coordinates in variable or something...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Great, thanks.

    I was setting most of my events to be formula based, thinking that is cheaper, but i prefer using "on collision" and "is overlapping" conditions.

  • Ashley

    Is there a way to use only the cheap collision tests based on the bounding box, without using the actual polygon check after. Or maybe the 4 point poly checks is as fast as the simple collision check?

  • I was always wondering how much better is to use simple distance check like (Obj1.X - Obj2.X) < 100 ; (Obj1.Y - Obj2.Y) < 80, than using collision checks?

  • There is a Unit update if anyone is interested :)

    Still needs alot of polish but the base is done.

  • I see

    I'm new to all that scripting/coding stuff so excuse my ignorance :)

    So you are saying Magistross that using collisions for detection also runs check every tick for all units? Not good.

    I'll try your approach and will run some stress tests.

    Thanks

  • Yeah Magistross I remember that well since it works fine for my woodcutter to find the nearest tree. In that case I needed it now and then when the last cutting tree gets exhausted.

    In this case tho, I need an event ran every tick. I imagine making calculations about every unit in the field every second gets too much.

  • Thank you both guys for showing that interest in the topic

    The calculations showed will help me great deal about some other stuff i need to implement so learning that trick is quite useful for me.

    Anyways, after a long evening in testing i think i got what would be the most comfortable for me to use. Since I am no programmer and my math is intermediate, and my trade is more like art orientated than coding, i prefer the visual than the logical approach.

    The 8 point collision poly is not quite accurate by me since i will have graphic appearance of the ellipse, so i divided an invisible object in 2 frames, each frame containing opposite semi ellipse collisions, so in fact i get a 14 pointed collision of the ellipse.

    <img src="https://dl.dropboxusercontent.com/u/19082408/789.JPG" border="0" />

    Blue line is the 1st frame collision

    Yellow is the 2nd frame collision

    I haven't yet tested it but i feel confident it should work as expected.

  • Thanks a lot for the answer

    Math is not my brightest side but i think i got the idea... I'll try it out tonight when i got home.

    The problem i see with this is that i should every second make this calculations about every unit on the field. Since i plan to have many units i dont know if that is the right approach. Maybe i should simply detect distnaces between the 2 units, and only if the distance is smaller then the largest radius of the ellipse, only then to make that calculations and see if the other unit is within the ellipse radius? What u think about it?

    Anyways if anyone can answer my question about the collision polys with more then 8 point i will greatly appreciate it, i was often wondering about it:

  • Hi guys

    I have a problem, or more like dilemma, about detecting units in elipse range. Here is what i mean:

    <img src="https://dl.dropboxusercontent.com/u/19082408/123.JPG" border="0" />

    So, as i see it, there are 2 approaches about this:

    • First approach is to make a collision surface, detecting foes on collision. That have many advantages, but one main downside - the 8 pointed collision polygon is not enough to make a decent looking detection. When trying to add more points (16 would be enough as i see it)it sais all collision polygons over 8 points are very havy.

    So there is my question: How exactly expensive is to have polygons with more then 8 point? (is having 16 point polygon twice as heavy as to have 8 point poly, or there is another cunning reason we shouldnt make more then 8 points?)

    If there is such reasons i can make it works by setting the sprite with 2 frames, both to have slightly different 8 pointed collision polys. So i figure if i play the animation fast it will detect foes for both the yellow and the blue collision polys.

    <img src="https://dl.dropboxusercontent.com/u/19082408/456.JPG" border="0" />

    • Second approach is to make it by detecting distances. But the problem is, because of the camera angle, i want it to be an ellipse, not a circle. Im not sure if that is possible to make with the -Get Distance To-. The only way to achieve this, as i see it, is to have a hidden layer with all the foes and rally points, and keep it scaled so it becomes like top view (not even sure its possible).

    Anyways, if anyone have any thoughts or advices for me, and most of all answer of my 8 pointed collision poly question, pls dont hesitate to write.

    Thanks for baring with me and my problems ;)

  • Hi guys

    I'm making an orthographic kind of game. Its not top view, but 3/4 or something, so I'm trying to simulate the perspective, meaning units walking up and down move slower and moving sideways move faster. That i managed to make quite simply, and i think it feels alright (just changing the pathfinder speed along with the sprite animation for direction).

    My problem is that i cant make the pathfinder find a path, obeying that rules (when destination is up or down, the cost to be higher, and when it's sideways, the cost to be lower)

    Sadly I think i cant do that, not with the pathfinder as it is, and my programming skills at so low lvl as they are.

    Anyways i thought its smart to ask before cutting that out. So anyone have any idea how to do it?

    Thanks

    NB: You can get the idea if you start the game and create a barracks.

  • I think i got it running.

    I had some problems like ome6a1717 said, adressing the units.

    Since the unit is in the family, it seems to detect the distance to itself. So here is what i did

    For each Unit

    distance(Unit.X, Unit.Y, Family.X, Family.Y) < 20

    Unit.UID not= Family.UID

    I got a lot of work on the movement of units, so its really smooth and logical, but i think i got the main idea.

    Thanks

  • Thanks TELLES0808. Looking at it now, at work, where i cant start construct2 to try it out, is hard for me to understand, but i think i got the idea.

    Tonight ill try it out.

  • You are right TELLES0808, comparing distances seems better than collision checks. I guess an For Each condition is on order so this happens every time units are too close.

    That leaves me with the second problem - the action.

    The units are supposed to gradually push away from each other. Even more it's supposed to have in mind all other units around it. Frankly I have no clue how to achieve this.

    Any ideas?