RTS & Yield?

0 favourites
From the Asset Store
10 isometric and animated Strategy Game Buildings in two Colors.
  • Hi,

    I am searching for a solution for a Realtimestrategy Game, so that enemies moving along a path avoid each other in realtime.

    Rather I am missing this feature in the actual RTS Template.

    Is there any (clean) solution available?

    Many thanks <img src="smileys/smiley1.gif" border="0" align="middle" />

  • There is a pathfinding behavior that supports this functionality.

  • i guess you mean so they don't overlap, pathfinding alone wont cut it,

    maybe an idea for an avoidence behavior or extension on pathfinding

    here some interesting links


    Subscribe to Construct videos now

    ps: h?h? great this guy recreated c&c in javascript,play online

  • Thanks for your suggestions.

    cow_trix: which one do you mean? the internal supports "regenerate obstacle map", but this feature does not work as expected in my project, even if i am using a "soft collision radius".

    vtrix: my idea is simple: every tank got all other tanks as obstacles. when collision is recognized, one of the "colliders" regenerates its obstacle map. anyway I made it, but it wont work. So i am searching for a kind of script example.

  • xeed

    As said before, the pathfinding can't do "all" the work here. It can help a lot though.

    When you regenerate obstacle map, it doesn't work because you have some moving obstacles (other tanks) and the obstacle map cannot use those.

    Instead, remove the other tanks from the obstacle map completly.

    In fact, the pathfinding is correct, it founds a good path. It's the "move along path" that doesn't do it correctly for you. Instead, you should code your own movement, making the overlapping tanks stop moving maybe (so they wait for the road to be open again). If you go down this road (haha), take a look at the "Pathfinding.capx" example in C2, as Ashley displays all the nodes on the road found by the pathfinding. It will be useful to build your movement.

  • A condition as "Select all instances, but (self.IID)" would help a lot.

  • it's simple.

    each.. let's say 0.1 or 0.2 sec regenerate obstacle map

    and subevent - foreach - instance - find path to... whereever it was moving to (through their instance variables set them to x,y) and then move along path.

    i've tried for 10 boats in my game - works sofar good, BUT! when you get to let's say 100 instances or more, it might get laggy + work badly if CPU is weak, because it uses a lot of CPU power and there's a lot of sprites with movement - lots of calculations.

    so to ease it up - you could set them to solids, add custom movement and on overlapping add - "push out nearest" - then reduce pathfinding to let's say... each 1-2-3 sec or simply remove the foreach and let it calculate just once(if your objects are static!) if your objects are moving you will have to use that loop

  • Thank you.

    How did you set only other instances as obstacles? If I add all, they see themself as obstacles too... so they can't find any path, being blocked by their own instance.

    Another way would be to remove an obstacle from the obstacle map. But I can't see a way to do that. I might create another thread for this problem.

    Would be nice if you could share a capx.

  • A condition as "Select all instances, but (self.IID)" would help a lot.

    var myIID

    pick all object

    pick object by evaluate where object.IID <> myIID

  • Thank you very much.

    I tried this before, but did not pick all object instances before the evaluation.

    Is it really needed to pick all before, and why?

  • It depends on which level the picking takes place.

    I just gotten used to applying pick all in cases where its a subevent, or part of a list of events which do more pickings ...

  • The temp-solid solution of saiyadjin works pretty well, but only using solids as obstacles. These are moving obstacles, where the moving should use each other as obstacle, but not themself. So there is heavy CPU-load and I dont think this is the right solution.

    I also tried your idea, but no success so far. Maybe you can provide a more detailed event.

    Could it be that obstacles can not be set per instance (when not using solids as them) ?

  • The custom movement has an option called "Push out solid", Rex also has a behavior named the same. It might be an easy patch.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you.

    But Isn't it the same if I disable solid for each instance before creating a new path - and when path found, enable solid again?

  • Thank you.

    But Isn't it the same if I disable solid for each instance before creating a new path - and when path found, enable solid again?

    The push out solid, might be an approach in which you do not need to do anything else, but just let the colliding happen and it could sort itself.

    The objects will not overlap, but one will simply get pushed aside while traversing its path.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)