[SOLVED] How do I intances seek instances

0 favourites
  • 7 posts
From the Asset Store
Make your game more fun and interactive with the Dog Hide and Seek Buttons Sprite Sheet.
  • Hi all

    how simply spawn two kind of object, every for a number of instance like a variable "Random", and named for example "red" and "blue". So on the screen i suppose for example to had 5 instances "red" and maybe 9 instances "blue".

    well, what i need to understand is : how is possible that every instance "red" follow the nearest (distance to them = 100 pixel) instance "blu" ?

    (If instance "blu" distance is upper 100 pixel than instance "red" go to stop.)

    thanks for help

    code:

    layout:

    i cannot attach the link of .capx i do not why?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • what is your cone of view set to?

    re: layout picture...which one is red#1? the one facing the blue or not facing?

    • red pick nearest instance of blue

    -- system compare values - distance(red.x,red.y,blue.x,blue.y) < 100

  • - red pick nearest instance of blue

    -- system compare values - distance(red.x,red.y,blue.x,blue.y) < 100

    tnx to both, well, i've semplify the project

    now i had 5 instances "red" and one "blu"

    blue : behaviors : DragDrop

    red : behaviors : Bullett : initial speed 0

    all seems work fine, but only if i created 1 instance of "blue"

    if i created for example 2 instance of "blue" the projects run crazy....

    i need that every reds seek the instance of blue nearest of itself

  • If I understand your problem correctly, I think I would do something like this.

    -For Each 'Red'

    --Pick nearest 'Blue' to 'Red'

    ---If Distance('Blue' to 'Red') < 100

    ----'Red' Set Bullet angle towards 'Blue'

    ----'Red' Set Bullet Speed = 50

    -Else

    --'Red' Set Bullet Speed = 0

    I hope it makes sence and that it will be of help.

  • I hope it makes sence and that it will be of help.

    Wonderful!!!!!!! Many thanks!!!!! Its work you are a genius!

  • Happy to help!

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