0 Favourites

Collisions between Sprites [Sprites,Pathfinding, Families]

  • 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:

    My "collision" event looks like this:

    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?

    Best regards,

    Proxy

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Are you using the native pathfinding behavior at all?

  • 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 <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    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:

    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 <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";-)" title="Wink">

    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.

  • 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")

  • 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?

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

  • 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:

    Collision detection looks like:

    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

  • 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 )

    Best regards,

    Proxy

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

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Sprite Font Generator - v3
368 112,273
RetroDaddy's avatar
RetroDaddy
Unread hot topic
86 28,702
St4rDu57's avatar
St4rDu57
Unread hot topic
153 104,423
DravenX's avatar
DravenX