Collisions between Sprites [Sprites,Pathfinding, Families]

Get help using Construct 2

Post » Sun Mar 06, 2016 6:54 pm

Hi there!

Im sure, this has been already asked and answered, but I didnt found something.

I got: "Sprite_Minions" which is part of the family "Fam_Minions". They both the bools "Playercontrolled" (bool in family instanced) and "Minion_playerowned" (bool in sprite instance). I think you now know where this heads to... ;)

"Sprite_Minions" are getting spawned in dynamic intervals, so the amout of them for both player and enemy is changed every nth event/second.

To my question:
Duo to the ongoing spawning of "Sprite_Minions" for both players with the same sprite as source, I created the bools "Playercontrolled" and "Minion_playercontrolled" on sprite and family.
Movement is set by engine, so the player got no control over where the minions move.

Creation of minions looks like this:
Image

My "collision" event looks like this:
Image

Now, collisions for "players" sprites are working - minions are stopping (from moving over found path) and showing the attack animation caused by function "minion_attacks_enemy", while the sprite which is owned by enemy just walks through him, totally ignoring him.

I think the mistake isnt in my source, I think its my logic... but I havent figured out an another way to do such in a decent way.

Does someone got me an elegant answer for this? :x

Best regards,
Proxy
Last edited by Proxymity on Mon Mar 07, 2016 11:34 am, edited 1 time in total.
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Sun Mar 06, 2016 7:08 pm

Are you using the native pathfinding behavior at all?
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,594

Post » Sun Mar 06, 2016 7:24 pm

LaDestitute wrote:Are you using the native pathfinding behavior at all?


Yes. Idea was to put different obstacles (fences, trees, etc.) on the gamefield. But then I noticed how crappy pathfinding works.. but thats an another story :D

When a minion is spawned, nothing happens with his pathfinding. It gets calculated when the attack button is pressed. Heres the whole pathfinding stuff inside:
Image

Every minion gets his own target, that explains the loops.

Pathfinding should be stopped when "collided" and be started again when the combat ended (after no other minion from the opposite player is in range).

This is only needed for melee-minions, ranged minions are also in the "Sprite_Minion"-sprite. Ranged minions are not going to use the "on collision" object, I thought about realizing this with the turret behavior. When a melee and ranged met, range should start firing/casting and melee minion should walk towards ranged untill he collides with it and they both go into melee fight (ranged wont deal much dmg in close combat) I wanted to determine "what is what" by the animation which is played - but thats an another story.
Simply the "collision" between melees (or in this example Sprite_Minions in general) is the only important thing here ;-)

Best regards,
Proxy


Edit #1:
Heres what it looks like http://proxy.wtf/strategik/ - but this is just a "tech demo". I havent included any "gameplay" functionality. First I need the engine.
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Sun Mar 06, 2016 8:21 pm

Create a new condition (On start of layout) and in it, add any solid objects you have (the player, minions, trees, treasure chests, signs, etc) to pathfinding obstacles (should say "Add pathfinding obstacle") and then after that, also add "Regenerate pathfinding map")
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,594

Post » Sun Mar 06, 2016 10:41 pm

LaDestitute wrote:Create a new condition (On start of layout) and in it, add any solid objects you have (the player, minions, trees, treasure chests, signs, etc) to pathfinding obstacles (should say "Add pathfinding obstacle") and then after that, also add "Regenerate pathfinding map")


Thanks. But does this fix the problem too? The sprites dont have a solid; do they need one if collisions between them should work?
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Sun Mar 06, 2016 10:49 pm

You might need solid for the sprites, unless you're completely coding custom collisions.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 521
Reputation: 19,594

Post » Mon Mar 07, 2016 6:22 am

LaDestitute wrote:You might need solid for the sprites, unless you're completely coding custom collisions.


Tryed it, but it doesnt work like I want it to. Its very much the same without a change (since Im using the "normal" "on collision" which isnt pathfinding related - I think).

Start of layout:
Image

Collision detection looks like:
Image

Here you can try it out yourself (click on the bottom buildings to open build menu; after every tick (time shown top left) minions are spawned; clicking on the shield-symbol lets them attack):
http://www.proxy.wtf/strategik
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Mon Mar 07, 2016 11:34 am

I hate to do so, but: bump

Can't figure out noone of you knows a proper solution to this (or at least I hope so :x)

Best regards,
Proxy
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Mon Mar 07, 2016 8:27 pm

Shouldn't you have Fam_Minions:Stop there as well when they collide? It looks like your only telling one of them to stop.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Mar 08, 2016 6:50 am

ramones wrote:Shouldn't you have Fam_Minions:Stop there as well when they collide? It looks like your only telling one of them to stop.


Thanks for the answer, but no, it doesnt work. :-/

Problem at this point is, that the pathfinding is calculated for the Sprite_Minions, not the Fam_Minions.

Maybe a way could be calcluating the path for both instances, but this would head to double cpu usage and it isnt really needed (at least I hope so).

Any other ideas?

Best regards,
Proxy
B
24
S
14
G
9
Posts: 118
Reputation: 6,799


Return to How do I....?

Who is online

Users browsing this forum: David181 and 17 guests