Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity RTS Engine

Discussion in 'Assets and Asset Store' started by OussamaB, Feb 7, 2017.

  1. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    So I made several tests now since the AI components are working better and I think according to my need but also for most cases of users, the AI behavior needs some strong tweaks.

    The first one is to offer the possibility to have a builder separated to the collector in order to extend the possibilities of gameplay without crippling the actions of the AI.
    I can do this now but for the AI I use the spawn components to be sure that the AI will not be stucked.

    The second one is to help to define build orders like in all RTS.
    You idea to define a behavior which calls the requirements depending of needs is good but I think that it is completely ruined by the fact that :
    - you don't have a tech tree function for a faction to define requirements to build one or another building;
    - the AI just try to put all buildings without taking into account that she wastes all resources in this.
    For this, I have used the border component for each building to define which building will be built after another one with a special timer but this is not comfortable also. It works but this is not the best way to do that.
    In an other hand, the border component is very interesting to design some AI behaviors to place buildings. It is a good tool. I would take this as a sub designer for AI behaviors to put turrets around resources or mines for example to protect a special area. I think that this could be extended to be more usefull.

    One simple way to do this I think :
    Use the NPC building component and in the list of buildings add a timer for each building (with a random factor or not) in order to define exactly the order of production for the AI.
    You can use a list of a list in order to define several build orders picked randomly for each game.

    The main fact is that for example in this case below I have destroyed her factory and the AI doesn't rebuild it. She spams generator which generates a resource not used and she's completely without any defense except with the airfighters (cannon fodder)...
    I really would like that the AI rises the factory as fast as possible.



    Linked to this and discussed before, could you add a tree for buildings dependancy to have several tiers with ou without upgrades of buildings?
    Maybe you can add a tech level variable and a list of requirements for each building component?

    Continuing for AI topic :
    The AI definitely needs several attack groups.
    I would split the NPC army component or create a list of attack groups.
    I saw that she attacks when the common group is filled and strike the HQ, ignoring the players units.
    This is not really fun to counter or play with.
    Balance between fun to play and challenge to survive :rolleyes:

    I have also seen that the local AI of each unit prefer to select its own target over the player choice if something seems to be more relevant and if something is attacking the AI.
    It is fine for the AI side, but this behavior is not acceptable when you are the player since your units don't react to your orders. Bad experience for a RTS player in all cases.
    The player's order should not be modified during an active phase - but we can have automated behaviors in a passive stance.

    I have noted that the option to select several units by a dragged rectangle doesn't work if we cover a part of a building.
    This is annoying.
    I have also seen that sometime the double click only select few units of the same type on the screen and some other are not selected.
    These two points need to be investigating since this reduces the control of player on his army and this is very difficult to do fast actions during a fight.

    I have also a request concerning the AI goto point and maybe this can be applied to the player also : could you are a small area around the goto point where the AI can select a destination in order to avoid the flower of units which look at the same point? Some RTS use with to avoid this effect or create a grid to park the new units.
    The bad thing now is that the AI produce units and if they are several units they are blocked on the entrance of the factory. Sometimes stucked completely.

    An other way to avoid this, used in most RTS, is to define a rally point for the AI only where she locates her army before a strike to avoid this effect. This could be usefull.

    EDIT :
    One additionnal question: if the AI doesn't have a LoS on the target, the AI unit will move to a location with a valide LoS or will she stay passive at its location?
     
    Last edited: Jul 30, 2018
  2. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    On my to-do list.

    So a system that defines buildings that the AI can place with amount required per building center and with priority should solve this issue.

    A tech tree has been previously requested but I believe with the new Task System, it should be easier to add now.

    You're right, this needs to be tweaked.

    In addition to this what do you think about an AI Wandering behavior that makes a certain amount of the army units wander inside the faction's territory?

    It will rotate until the enemy is in its LoS.

    --

    The next update will feature a global faction & resource definer so that you don't have to re-create everything for each map you're configuring. That will be the main theme of the upcoming v1.3.3. However v1.3.4 will only feature AI improvements and I will take into consideration all what you mentioned above, so I ask for some patience for this.
     
  3. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    This could be an interesting behavior to have a more dynamic opponent.
    In a previous modded game, I used something like this to make some patrols around the AI base to avoid attacks from behind.
     
  4. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    You said that in the current update the turret problem where it didn’t react was solved but I'm trying to define a basic building with an attack component and I obtain no reaction from the turret against my coming units.

    How I can solve this or verify what I need ?

    Edited : Problem solved

    I finally managed to find the issue.
    In the attack component when we define a building as attacker, three parameters are missing.
    We need to modify the attack editor to restore : attack in range/search range/search delay
    Without this, the building doesn't pass the test to search around for nearby enemies.

    Full fonctionnal deadly turrets on the way now :cool:
     
    Last edited: Aug 6, 2018
  5. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    I have also a question concernant the auto rotation of units in the Unit.cs script.

    I was a bit surprised by the behaviors of turrets on units which were a bit useless since the units are always rotating to the target and the turret doesn't really have the time to rotate.

    I have neutralized these lines in the script:

    if (LookAt != Vector3.zero)
    {
    //Quaternion NewRot = Quaternion.LookRotation(LookAt);
    //transform.rotation = Quaternion.Slerp(transform.rotation, NewRot, Time.deltaTime * RotationDamping);
    }


    And I get two interesting things:
    - when we move several units, they stop to face to the targeted location "in flower" (I don't like to see my units doing a meeting on the battlefield :D)
    - units with turrets have only the turret which rotates when we attack an enemy so the behavior is widely close to the real behavior wanted for turrets

    The bad side is that common units without turrets don't face anymore the target.

    So I think that you should do two things to have the best behavior of units:
    - create a boolean to define if the unit has a turret or not and neutralize the rotation of the main body when she attacks to let the turret faces correctly the target
    - suppress the rotation step when the unit or units are simply moving to a location.

    I have done quickly these two changes in your unit.cs and I can say that this is really enjoyable to get the correct behavior. ;)

    You can see here my test unit with the turret facing the enemy building on the opposite of the front of her body:



    I have just done this by a boolean which neutralizes the two lines if we checked in the unit editor that we have a turret on this unit. So very little modification for a great effect.

    EDIT : Additionnal question :

    Is there a way to have the turret fire only when she faces the target ? Sometimes she fires before being exactly on the line of the target.
    Can LoS help in this case ?

    LoS is applied to turret when the unit has one ?
     
    Last edited: Aug 6, 2018
  6. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    A small question:

    When I build a structure, I have always the beginning of the green bar which is not located exactly to the beginning of the orange bar - this is only the case for this bar, the others in the UI are fine.

    How I can define the good location ? I have compared the green and orange components in the HealthBarCanvas and they are located exactly at the same location.

     
  7. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    There's a missing field in the Unit's component inspector under the movement settings and that is the "Rotate when idle?" toggle field. That allows you to allow the unit to fully rotate to face its target (destination) when it's idle after completing its movements towards that particular target. So yeah, that toggle field actually delivers what you want. I'll add it in the next update (I can also send you the modified version of the Unit component editor so you don't have to wait for the update). I'm also planning to slightly change all custom editors to look like the recent Task Launcher editor so that everything can be broken down into tabs and it won't be overwhelming as it is now.

    In the LoS configurations (on the Attack component), there's a toggle field called "Use Weapon In LoS" which when enabled, will the use the assigned weapon object in the Attack component (in this case, the turret) as the reference for the LoS calculations. While disabled, the main unit object will be used a reference for the LoS.
     
  8. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, that is indeed missing, thanks a lot for pointing this out and as always, it is much appreciated.
     
  9. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, I have been aware of this issue since a few days now and it will be fixed. Will let you know as soon as I have the fix.
     
  10. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    72
    So I just updated to version 1.3.2 and am having a couple issues. First, whenever I build a unit, it removes the animator controller so the units don't animate. Second, the units won't move when I right click on the map, only if I right click on the mini map. Everything worked perfectly before the update. Any ideas? Thanks! :)
     
  11. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    For the movement of your units, the terrain manager has been changed, maybe you need to check if you always have the right layers defined in this manager.
     
    jobo22 likes this.
  12. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    72
    That was the problem, I had to set the ground terrain mask to terrain. Thanks tons!
     
  13. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Hello i got small problem ! i am sure its on me and i forgot somethings.
    I am working on copy of demo scene, I made my buildings prefabs change variables of them in game manager and factions etc but still enemies area building theirs old prefabs from asset. What did i forget about??
     
  14. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    I can wait the next update thank you.
    Just good to know that this behavior will be possible soon.

    I have also a question concerning attack objects :
    They are destroyed each time they enter a collider - right ?
    If I generate a cloud of small objects with colliders on them, the attack object could be detroyed if he hits one of these colliders - right ?
    Or the code limits the interaction only with colliders linked to units and buildings ?
     
    Last edited: Aug 8, 2018
  15. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    Concerning upgrade function - I have several questions:
    - I tried to define an upgrade on my HQ with a version lvl1 without a shield and a version lvl2 with a shield
    I have defined all entries on the lvl1 HQ to upgrade to the lvl2 prefab with a requirement of resources and with or not depending of the test case of another structure (tech center in this case).

    I can see the Upgrade button if I check "directly" in the component but nothing happend when I click on the button.
    In all cases of test even with no condition of resources and buildings the button has no reaction.

    > Is there a problem of a link with the button in the UI maybe ?

    I see this in the button panel :



    I have modified the task button to select the upgrade building task but nothing happend.
    I see a missing entry on the component on top of picture.
    Something linked to this ?

    - Also if the function is functional - how does it work for the AI and the builder:
    > All upgraded buildings are replaced in the buildingsmanager by their new versions ?
    > The builder panel has also new icons linked to the new upgraded prefab?
    > Do we need to list all buildings for the AI in the NPC building component including the upgraded versions or the link is automatically made in-game during the process of update and she knows what she need to use and build after an upgrade?

    - Concerning the upgrade of a building: if we destroy an upgraded building, we can build again the same version or the building available will be the initial version?
     
    Last edited: Aug 8, 2018
  16. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    To help, from what I know and understand, you have the list of buildings in:
    - building manager
    - in each faction manager in the NPC building component

    You have also a component which contains two buttons :
    - update list of spawnable buildings
    - reset list of spawnable buildings
    This component is somewhere in one of the managers - just look at each one by one.

    Maybe this is this one where you need to reset and update the list by clicking on each button since you say that you have already updated the list of prefabs in building and factions components ?
     
  17. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    I reset update them still doesnt work. Yes i changed faction list.:
    upload_2018-8-9_11-13-18.png
     
  18. AmRafay1

    AmRafay1

    Joined:
    Oct 22, 2013
    Posts:
    636
  19. JackieFPS

    JackieFPS

    Joined:
    Mar 17, 2014
    Posts:
    3
    Why am I getting this error please

    Code (CSharp):
    1. Assets/RTS Engine/CustomEventsExample.cs(31,40): error CS0117: `GameManager' does not contain a definition for `PlayerFactionID'
     
  20. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Hey there, did you setup the buildings in the NPC Building Placement component?

    EDIT:

    You should also have a look at the Border component of your building centers. You can define buildings that a NPC faction must place there as well, so make sure you don't have any old buildings assigned there.
     
    Last edited: Aug 10, 2018
  21. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Not destroyed but hidden and available to be re-used again.

    You can technically assign a collider for each child object and then whenever a child object enters in collision, you simply call the code that assigns damage from the parent object (one that holds the Attack Object component). But yeah, per default the interaction is only linked to the object that has the Attack Object component.
     
  22. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, on the missing entry, assign TaskUI -> OnTaskClick.
    And yes you've correctly fixed the Task Type field in the Task UI component.

    Yes.

    Yes.

    Only the base buildings, not the ones that you get after an upgrade.

    Building upgrades are handled like research, once you've unlock one building upgrade, it simply means that you are now able to place the upgraded building so yeah, if the upgraded building is destroyed, then you can place the same version again.
     
  23. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Hmm, have you modified the Game Manager component? Or the component that produces the error?
     
  24. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Done. Check your inbox.
     
  25. giotta

    giotta

    Joined:
    May 31, 2015
    Posts:
    36
    Hi,can this asset work with isometric camera ?
     
    Last edited: Aug 12, 2018
  26. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, you'll probably have to adjust the camera's movement behavior though.
     
  27. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    How can we manage several turrets on a single unit ?

    Can we add several attack components to a single unit to do this ?
     
  28. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    You have two options:

    1) You want to fire from all turrets from one attack: For this you simply define multiple attack sources in one single Attack component.
    2) You want to switch between turrets for each attack: For this you simply add as much Attack components you need and add the Multiple Attacks component so you can be able to switch between different attack types.
     
  29. KevinVon21

    KevinVon21

    Joined:
    Feb 5, 2017
    Posts:
    2
    Hello, first of all, wonderful work guys.. i am a computer science student and i want to know if i may be able to buy and use your rts engine available in Unity Store as the base for my rts game.. can i modify it by adding my code? And can i add new features to it for my personal game? Thank you
     
  30. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    All source code is available so you can modify it all. While most built-in features can be customized just from the inspector, you can customize them further by modifying the code.

    The asset also comes with custom delegate events that are triggered whenever a major action happens in the game (for example: OnUnitClicked, OnTaskLaunched, OnFactionDefeated, etc...), this makes it easier to extend the engine through your own code.
     
    KevinVon21 likes this.
  31. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    I have found two bugs with the converter component.

    The first one is linked to the two lines below in bold.
    They need to be moved in the if group or we get a null exception error and the unit is not converted.

    //Clear all the pending tasks.
    TaskMgr.TasksQueue.Clear();


    Code (CSharp):
    1.             if (TaskMgr != null)  //if the unit has a task manager
    2.             {
    3.                 //If there are pending tasks, stop them and give the faction back the resources of these tasks:
    4.                 if (TaskMgr.TasksQueue.Count > 0)
    5.                 {
    6.                     int j = 0;
    7.                     while (j < TaskMgr.TasksQueue.Count)
    8.                     {
    9.                         TaskMgr.CancelInProgressTask(TaskMgr.TasksQueue[j].ID);
    10.                     }
    11.                 }
    12.                //Clear all the pending tasks ->>> Moved to the if
    13.                 TaskMgr.TasksQueue.Clear();
    14.             }
    The second one I can not solve by my own is the effect after convert action.
    The unit is converted but the effect is played in loop without end at the initial location of the targeted unit.
    Any idea to suppress the effect after the first run ?

    Code (CSharp):
    1.             //spawn the convertion effect:
    2.             if (Converter.ConvertMgr.ConvertEffect) {
    3.                 Instantiate (Converter.ConvertMgr.ConvertEffect, transform.position, Converter.ConvertMgr.ConvertEffect.transform.rotation);
    4.             }
     
  32. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    37
    Is it possible to use the events system to create UI button. I would like military building to have its own selection from the resource buildings.
     

    Attached Files:

  33. II_Spoon_II

    II_Spoon_II

    Joined:
    Jun 16, 2018
    Posts:
    103
    I would like to know more about the Multiplayer mode, how advanced is it? Does it manage everything we need in multiplayer and we can launch it, or still needs networking line codes?
     
  34. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    Can the AI upgrade her buildings or her units?

    I don’t remember if i asked this before.
     
  35. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Thanks a lot for letting me know about this, fix will be available in next version.

    I guess that depends on how you set up the converter effect but that doesn't matter because I need to make the Effect Object Pool component manage this one as well, which will of course be included in the next update.
     
  36. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Are you referring to having sub categories in the building list panel?
     
  37. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    I just answered you per e-mail, check it out and let me know if you still have any more questions
     
  38. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, managing how the AI faction handles its building/unit upgrades can be done through the NPC Resource's component (under Task/Building Upgrade Settings).
     
  39. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    37
    Yes
     
  40. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Okay, the asset offers a task panel category feature and this allows you to assign tasks button to be children objects of different parents. Now you can write a component that handles the different task parent objects and have your own buttons to enable/disable these parent objects.
     
  41. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    A target for the release?
     
  42. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Early next week.
     
  43. KevinVon21

    KevinVon21

    Joined:
    Feb 5, 2017
    Posts:
    2
    One more question, how hard is the hard mode AI? Does the Hardmode AI Nation invade?
     
  44. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    72
    Hi, I have a question about the LOS. It works how its set up right now, but I would like to make obstacles that units can't shoot through, such as big rocks or ruins and stuff. Right now the units will shoot through objects that have a collider on them. Could you make it so there is a layer we can put certain objects on that we don't want the units to be able to shoot through? Thanks!
     
  45. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    The AI can be easily configured through three main components: NPC Army (which mainly handles attacking & defending), NPC Building Placement (handles buildings) and NPC Resource (which handles how the NPC faction collects and spends its resources). These three components can be configured from the inspector, you can easily make a NPC faction that can be very challenging by tweaking the fields in the mentioned components.
     
  46. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    Yes, currently LOS ignores objects, I've added this in my to-do list. Will let you know as soon as it's available.
     
    jobo22 likes this.
  47. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    87
    One question concerning the map size in the game manager.
    By default this is defined to 150 but 150 is linked to a real parameter?
    In the documentation the value is said to be used for the expansion of AI but how is it considered?

    Is it a ratio between X/Y lengths of the map or something else?
     
  48. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    You simply input the size of the map you have and then assign the percentage that the AI faction aims to have under its territory considering that size. HOWEVER, I would like to change how that works (especially how the AI handles expanding since that's something that I haven't touched since the release of the asset). It's already on my todo list for the next AI update.
     
  49. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    I just submitted v1.3.3 to the store. It should be available in a couple of days. Here's the full update list:
    • New Features:
      • Added a "Rotate While Idle" toggle field in the Unit component inspector that enables/disables the unit's rotation when it's idle.
      • The Attack component for buildings now has the following fields in the inspector: Search In Range (toggle field that enables/disables attacking units in range), Search Range (defines the range where the building searches for enemy units to attack) and Search Reload (attack in range search reload time).
      • The audio clip that's played when a unit is sent to collect resources can now be chosen from each unit's Gather Resource component.
      • You can now create the Faction Type Info asset in the project to create/define a new faction type and then use that same asset files in maps and menus.
      • You can now create the Resource Type Info asset in the project to create/define a new resource type and then use that same asset in different maps.
      • Custom edtiors for both Resource Type Info and Faction Type Info assets.
      • You can now assign a target unit to an attack building (tower for example) by selecting the building and right clicking on the target.
      • Moved Task Components settings from the Unit Manager to the Task Manager component.
      • Added the Attack component task to buildings that have an Attack component: select a building that has the Attack component and an icon will appear on the task panel which allows the player to select a target.
      • You can now choose for each building whether they can be placed outside the faction's borders or not.
      • Added a "Required Buildings" field to the Building component: define a list of buildings that must be spawned & built in order to place a building.
      • The conversion effect is now an Effect Obj and is now handled by the Effect Obj Pool component.
    • Bug Fixes:
      • Fixed the warnings appearing whenever an invalid animator override controller is assigned to a unit.
      • Fixed assigning a target to a converter.
      • Updated and fixed missing fields in the demo and menu scenes.
      • Fixed a bug that triggers the multiple selection box when placing buildings.
      • Fixed hover health bar positioning.
      • Fixed a bug that causes an exception error whenever a building cancels in progress task.
      • The building's selection texture now gets auto-enabled when the building is getting placed.
    As mentioned in earlier replies, in the next update I will focus more on AI behavior.
     
    jobo22 and digiross like this.
  50. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,118
    The newest update is now live on the asset store. Make sure to read the release notes to learn how to use the new features. Feedback is as always appreciated.