Bullet vs Pathfinding, any tips?

Get help using Construct 2

Post » Mon Oct 10, 2016 4:03 pm

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?
B
15
S
6
Posts: 236
Reputation: 1,939

Post » Mon Oct 10, 2016 4:47 pm

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?
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Mon Oct 10, 2016 4:50 pm

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 @badmoodtyler said, you shouldn't use both behaviours.
Please explain your project to us so we can understand why both behaviours might be necessary.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Mon Oct 10, 2016 6:00 pm

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.
Last edited by facecrime on Mon Oct 10, 2016 6:08 pm, edited 1 time in total.
B
15
S
6
Posts: 236
Reputation: 1,939

Post » Mon Oct 10, 2016 6:07 pm

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.
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Mon Oct 10, 2016 11:17 pm

If the Bullet behaviour serves only the purpose of following the player, you could replace it by
Code: Select all
Enemy: Set Angle to "angle(Self.X,Self.Y,Player.X,Player.Y)
Enemy: Move Forward X pixels
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed Oct 12, 2016 8:05 pm

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?
B
15
S
6
Posts: 236
Reputation: 1,939

Post » Thu Oct 13, 2016 7:07 pm

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).
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 37 guests