Bullet vs Pathfinding, any tips?

0 favourites
  • 8 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Hi everyone,

    I'm using bullet and pathfinding behaviour on the same objects and they seem to be conflicting on some occasions.

    For sake of a higher update frequency certain states of my enemies can switch from pathfinding movement to bullet movement.

    Other states however use only pathfinding and ironically those don't move anymore since I introduced the alternative bullet movement to the above part.

    I made sure to disable the bullet when not needed but the pathfinding-only state still won't move when it should. Could disabling the bullet block some aspects of the pathfinding?

  • I don't believe it is recommended to use two movement behaviors simultaneously—and I don't believe it is usually necessary either.

    Disabling bullet behavior shouldn't affect path-finding. But bullet behavior automatically moves (when enabled, so at the start of the layout or when created, etc). So are you sure you had the path-finding working to begin with? Or was it just moving because of the bullet behavior?

  • Hey man,

    I'd appreciate if you explained your project/implementation of Bullet/Pathfinding first.

    Because I can't really imagine many occasions where you would have an object with both behaviours.

    Either you have Bullet OR Pathfinding, but I don't know why you would use both, because they ARE indeed conflicting.

    Both behaviours control the object's movement in some way.

    The Bullet behaviour applies some Physics to the object which influences its x and y coordinates.

    The Pathfinding behaviour searches for a path and makes the object move towards it which influences its x and y coordinates.

    As said, you shouldn't use both behaviours.

    Please explain your project to us so we can understand why both behaviours might be necessary.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's necessary to switch between both when I need frequent updates of the target position vs when I need 'complex' paths to be resolved.

    Think of the zombie-type behaviour in a top down shooting scenario:

    When my enemies are spawned they need to figure a way around various obstacles to get in attack range of the player.

    This is resolved by pathfinding, but can only be updated every couple of ticks.

    When my enemies are close to the player (and have LoS) they use bullet to properly follow the player who is constantly moving.

    In most cases there will be no major obstacles in their way - if LoS were to be broken I switch back to pathfinding.

    Just check my old arcade example, it illustrates the situation perfectly:

    https://www.scirra.com/arcade/action-ga ... 10787?cp=5

    the first enemy you encounter has the issue where he won't move when he's supposed to 'circle' the player (see debug info)

    the following few enemies swarm you zombie-like, they apply both behaviours (see debug) and it works pretty nicely.

  • I get what you are saying, and that is fine if that is the way you want to do it. What I meant was one should always be disabled, thus not being used simultaneously. When enabling one then disable the other.

    My question still stands though—how familiar are you with path-finding? Disable the bullet behavior and debug the path-finding behavior. Use the debugger and a text box to figure out what is going on there.

  • If the Bullet behaviour serves only the purpose of following the player, you could replace it by

    Enemy: Set Angle to "angle(Self.X,Self.Y,Player.X,Player.Y)
    Enemy: Move Forward X pixels[/code:3bqx5zic]
  • good call, randomly, I looked into that and by all means that should have done the trick, if the problem was really in the usage of the behaviour.

    but after removing the bullet i still get the same issue, so the issue seems to be elsewhere. odd thing is that i have two states using pathfinding and only one keeps having trouble.

    it seems that the troubled state won't trigger the 'on path found' event won't fire, even though the set destination is valid, debug says it has a path, but won't set a speed.

    any ideas perhaps?

  • We will need more info at this point since what you provided as info apparently wasn't sufficient to solve the problem...

    Could you provide us with your capx?

    If your project is too big, just reduce it to what's important for the pathfinding (and bullet).

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