How do I difficulty working with instance?

  • Hello!

    I have a clash of clans game, and I'm trying to make units attack buildings and units.

    Only I can't understand how instances work, to detect enemy or nearest building and start attacking as expected.

    I'll say what I want in parts for the translation not to disturb:

    1 - Create unit with touch is right after she looks for the nearest unit to attack (I think I did it right)

    2 - Make the unit attack towards the enemy unit (this is being more complicated for me)

    3 - Soon after eliminating enemy unit move to another nearest unit

    here is the .c3p of what I could do

    https://drive.google.com/file/d/1UeOWLBUTO1VoFG0InekzgFrdFV8gZ8J8/view?usp=sharing

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your approach was correct, but you made a few mistakes. You need to use UIDs, not IID here, because IID is not a unique number. Use "For each" when there is a possibility that an event can pick multiple instances and you need to process each instance differently (say, pick a different target). I also recommend using Timer behavior instead of "Every X seconds".

    Here is the fixed project:

    dropbox.com/s/00lmkfa9f50grur/RTS_fixed.c3p

  • Your approach was correct, but you made a few mistakes. You need to use UIDs, not IID here, because IID is not a unique number. Use "For each" when there is a possibility that an event can pick multiple instances and you need to process each instance differently (say, pick a different target). I also recommend using Timer behavior instead of "Every X seconds".

    Here is the fixed project:

    https://www.dropbox.com/s/00lmkfa9f50grur/RTS_fixed.c3p?dl=0

    thank you, you can't imagine the light you gave to my project, I can now understand more about how instances work here.

    Thank you very much =D

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