How do I control my units as an additional separate ones?

0 favourites
  • 8 posts
From the Asset Store
SCI-FI Units SFX contains 456 sounds With this pack, you can voice almost all the units in your sci-fi strategy game
  • Hello,

    I wanna to make a kind of strategy game, but I stuck at one point because I can't control the units separately.

    For example, I have four unit and one of these ones have to go to cut a tree. In my game I can not do the "select one unit and send to the tree" method! I just select the tree and marking as cutting and after one (or more) unit automatically depart in direction of the tree and will cut it. Of course not the cutting the point, only the control over my units.

    So, the main problem that all worker units start do it instead of only one. How should I solve this problem? Something about the UID/IID? I don't know...

    Each units have a unique IID number. Somehow I should use it, but I don't know how should I give an order/action to only one unit.

    Condition:

    • If I clicked a tree

    Action:

    • A unit with IID 4 (or a random units) start to cut the tree meanwhile the others stay calm.

    Please help me I really need the solve it's an essential step! Or any tip/idea?

    Thank you all!

  • You can use "Pick random instance" and be done, but I guess you'd want the unit closest to the tree to go and start cutting?

    If so, you can use "For each" loop which will pick every instance one by one and store the distance of each one to the tree in an array. Then choose the one with the lower value and sent it there. Note that depending on the number of instances it could slow down performance.

  • you should create "states" like:

    IDLE

    MOVING_TO_TREE

    CUTTING_TREE

    RETURNING_WITH_WOOD

    Although it will be hard to only click the tree and have the system decide which "unit" to send.. you'd have to create some sort of identifier to isolate that this is the selected unit that is carrying out the last command. Otherwise there will be no way to pick it. And you will not be able to interrupt their behavior like in most RTSs i.e. select unit and issue a new command.

  • Here's a way to do it by picking the nearest unit

    dl.dropboxusercontent.com/u/14855413/nearest.capx

    As jobel said though, it might be difficult to implement in game

  • Scap if you do not find your solution send me a PM. I have some templates for common AI types. You can march in formations, and set up complex routes for them to follow.

    I have it so they can be as simple or as complex as you need. They can just march from way-point to way-point, or you can add special commands to the way-points, areas, and paths. (Like Rainbow 6).

    Well anyway you can use them in a commercial game, or you can just pick them apart and learn from them. Might save you a lot of time. PM me if you are interested.

  • here is my starting point - not very well documented by hopefully simple enough to follow

    https://goo.gl/F0YdZM (r215 plugins req rexs moveto)

  • Thanks guys it's working! I can separately control the units now if I want it. I used the Pick random instances and Nth instance. I don't know the array yet, but i will learn it as well meanwhile I make this game.

    Thanks for the exemples, I check this ones and try to learning more I'm sure that I will be more "beginner" questions in the future which will connect to this project. I hope you guys will help me next time too. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jojoe Of course I need these templates! Unfortunately I couldn't send a PM for you because I didn't reach the 500 reputations yet and until I haven't this amount (or more) not possible the PM sending. So, If you can send me one with these templates. Im sure it's going to be very useful for me! Thank you.

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