How do I make bullet and pathfinding work together ?

0 favourites
  • 5 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • Hello !

    I'm using in my project a sprite that has both pathfinding and bullet behaviors.

    I guessed that making them work together would not be simple, but it seems that I was underestimating the problem.

    So how do you make pathfinding and bullet behavior work together ?

    I tried to disable bullet speed while the sprite is using the pathfinding, but it does not seems to work with bounces (the sprite still bounces on contact with solid even though the bullet behavior is disabled).

    I tried using bullet speed to 0, too, but that makes the sprite vanish !

    I could make bullet and pathfinding work together, but then it causes some issues, like the sprite losing its path, and turning in circle past some speed.

    In this file you can see part of the problem: sprite vanish when colliding while moving along its path and colliding with bounce and speed = 0 (although bullet is disabled), and sprite 1 still bouncing on sprite 2 if you disable "set bullet speed to 0" in sheet 1, although bullet is disabled, too.

    (I'm not alowed to publish links yet so

    nacht. free.f r/public/speed0Bounce.capx

    just remove spaces)

    So my question is not how to workaround this case in the capx, but it is how do YOU make bullet and pathfinding work together with the same sprite ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I modified your capx.

    So I basically commented out the "bulit speed 0 ... you dont need it"

    on collision I disable the pathfinding, re-enable the bulit and add speed back to 200 like the speed you have in your pathfinding.

    The idea is you can have a bulit find its path to the target and bounce off normally... I hope it helps you out.

    Here's the new modified capx

  • Hello ! Thanks for your answer.

    This fixes the capx, indeed, but in fact in wouldn't work in many cases, like in my project. I updated my capx to be more like I use it in my game, and the fix cannot work anymore since the bounce event picks a family that does not have the pathfinding behavior (but sprite1 from this family has it).

    nacht. free.f r/public/speed0Bounce.capx

    I know that I could use exceptions ("do not trigger with this kind of object",...) but that wouldn't be very clean, and I'm sure there can be a way to properly prevent conflicts without having to deal with each different case for each object.

    The capx is just an example of those problems I met, how do I manage pathfinding with several object with bullets and bounces, but there are more, like bullet speed and pathfinding speed seem to add to each other, but I found nothing about it.

    Pathfinding and bullet are very useful behaviors, so I guess that many people use them both, but I couldn't find anything about the cohabitation of those two, and it causes many problems. So this is my question, do you have a method, or is there a proper way to make them work together ? Or is there some documentation somewhere ? Is this simply something to avoid ?

  • Usually I would make a function to deal with "repeatable situations" so that I can call it when needed. also I would keep the speed I want my objects to go at in a variable so that I can apply the value on the spot... I'll take a look at your new capx and see what I can make out of it. path finding and bullet behavior are useful in may ways .. "heat seeking missiles" directed attacks... interface dynamics. It just depends on what you want to achieve. I've come to the conclusion on many cases that Cnstruct 2 is flexible enough to do most anything with a little effort and a little help from the community. There's plugins that are very useful out there too... like the Move to behavior and some others.

  • Thanks, I'll have a look about plugins, but I managed to workaround my problems by switching like you did (and adding exceptions).

    And I definitely should use more functions.

    Btw I reported the vanishing sprite bug.

    Thank for you answer !

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