How do I Make Solid Sprite after drag and drop remain Solid on pathfinder?

From the Asset Store
Use inertion of your movements to throw, rotate your objects and etc. Objects can interact with others while dragging.g
  • hi,

    imagine a game close to tower defense. but without towers :P

    i have 1 spawn location 1 target location and some solid object in the layout.

    there is a timer that lets say every 5 seconds spawns an enemy unit the uni tries to find a path to the target and then it "moves along path" to that target avoiding the solid objects.

    so far so good.

    the problem is that i made my solid objects to be drag and dropable. so that i can move them around on runtime of the game. But when i move them the enemies keep using the original path they have found and ignore the solid new location, going throw them or just ignore them.

    why? how do i prevent that?

    regards

  • You need to use "Regenerate obstacle map" action. On a big map this can cause lags, so when possible try to only regenerate a small region. And after that, you need to refresh path for already moving units.

    "Regenerate" is completed on next tick, so your event may look like this:

    Drag&Drop On Wall dropped	
     -> Unit regenerate region around Wall
     -> Wait 0
    	Unit is moving along path
    	 -> Unit stop
    	 -> Unit find path to...
    
  • thanks mate. even thought i am clearly doing something wrong....somewhere with the "Regenerate obstacle map" i didnt get where should i use that, and then the rest, i have achieved pretty much the result i wanted. is just that is not instant,i mean some units that where already moving or some that they have been spawn pass through the solid objects and take a while for the next to "see them" and properly work.

    also because that idea fills a bit not good for my game, i want to simplify things

    and make the solid objects drag and drop Only before you "start the timer" and then do the spawn and since it will not be dragable i dont have to worry about the issues we talked before.

    enable and disable drag and drop is easy.

    but to my suprize this consept works the 1st time i run the layout

    and never again on the other attempts

    to stop the layout and reset it i use a button that does the following:

    imgur.com/a/iWxj5Oq

    but the solid objects now in a new location when the timer starts again is not reading new paths!?

    why? the path reading takes place after the unite is created, so it should do it like it did in the 1st times.

    very weird. i am must be missing something, that i need to "reset" to make the button actually tell the entire layout to behave that this is like i press f5 for the 1st time.

  • after lots of tries and playing with events around to understand how they will behave,

    the best solution i have so far is:

    the 1st spawned unit enemies ignore my moved Walls

    the 2nd and later all the rest work fine, an all Test attemps (1st f5 or any other, when i press stop or start button it will always give the same result)

    if i can understand why the 1st units are ignoring me that would be great.... it seems that because those sprites exist in the layout are behaving a bit differently from the ones "spawned" later on

    here are some screenshots an all my events that matter. :)

    imgur.com/a/WXSeZt2

  • Learn to use families - add all enemies to a family, remove Pathfinding behavior from individual sprites and add it to the family instead. With the family you will be able to reduce the number of events significantly.

    "Regenerate obstacle map" is only required if you add/remove/move obstacles, which I don't see you doing in your code. If you are only spawning new enemies, you don't have to regenerate the map.

    And if you do need to regenerate the map, just one action is enough, not six.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hmmm "families eh?" interesting. i will try to look into that. thanks a lot.

    but this doesn't change the fact that before any spawn takes place my counter says i have 3 enemy sprites created and it actually counts the 3 on the far edge of the layout.

    how do you recommend to avoid that?

  • re created almost all of it with families, global variables and stream lined the logic. and all works just fine now! i have a different question that i simply cant find an answer no matter how much i search or read the documentation, but i will ask that in a separate thread.

    thanks a lot!

  • i am forced to open this again because i was wrong. :/

    is driving me crazy so i give up for now.....unless someone points me to the solution.

    first of all forgive my various events i was trying everything i can think of and just to test similar events how the behave.

    to sum up,

    first run of the level if i drag and drop my solid walls the pathfinding works fine on my enemies.

    if i press the "reset" button i have made to start the level again from the start and then i move the walls again this time and from that time and onward, the new wall positions are ignored by my enemies!

    i clearly do something wrong in the "reset" button that i dont understand what and why is making the later drag and drop events useless. can anyone please find it based on my screenshot? :(

    imgur.com/a/EmEhIOd

    remember this doesn't need to happen on runtime. just prepare your "defenses" before you start your game type.

    if you see stupid things here remember. just started this weekend with c2 :P

  • You don't need 3 "regenerate" actions. Just one is enough. And like I wrote in the first comment, regenerate finishes on the next tick, so if you order your enemies to find path immediately, they will still use the old obstacle map!

    So you need to do this:

    Regenerate obstacle map around Wall
    Wait 0 // this means "wait 1 tick"
    Enemies find path
    
  • hi i did it as you said. still doesnt work.

    the 1st time only it works when i click my reset the walls are not taken into consideration.

    i also tried it in c3 just to see if there is a bug in c2 latest release.....but nope. the same "problem"

    imgur.com/a/0vEuGQf

  • i found the problem.

    your solution is ok, but the location of placing those events is wrong :)

    you see in my screenshots i was putting them when the drop happens of the wall.

    but if i put that when the enemy actually get created during spawn this is working always 100%.

    and now in combination with the drag and drop if i want to use it in runtime and move the walls it also works!

    imgur.com/a/n053PBE

    thank you.

  • Nah, all enemies should share the same obstacle map and you don't need to regenerate it for each new spawned enemy. So there is probably some other mistake in your code. It would help if you could share the entire project.

  • no offence sharing shots is not the same like sharing the entire project/idea here....

    even if is my very first project is many hours of work into this and you never know who will take advantage of your ideas, they can be altruistic or make fortunes from your generosity :P

    if you wish to drop me an email i would gladly share it with you in private. :)

    my email is exactly the same like my nickname [at]gmail.com

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