Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. 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. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Did you assign the Selection Obj correctly in the Building inspector? This seems like it's the case.
     
  2. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    I have, I removed it reapplied it restarted unity I don't know what it needs from me.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      324.2 KB
      Views:
      15
  3. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    So I've been digging into this issue and here's what I found:

    - When the speed of a NavAgent is too high, then it's recommended to have "Auto brake" set to true.
    - This issue is not connected only to flying units, I was able to reproduce the same bug with normal ground units as well.

    So a big change for how flying units work will come in the next update:

    - Creation of the air terrain will remain the same but it must now have its own set of layers (you can multiple layers for the air terrain tiles if you ever needed to) that need to be assigned in the Terrain Manager's inspector.
    - Air terrains must have their own layer while baking the nav mesh.
    - Air terrain must have trigger colliders so that they can be recognized by the Terrain Manager.
    - The height parameter in the Unit component role will be simply to simply define the base offset in the NavAgent (yes, I want to avoid any direct modifications of the NavAgent component).
    - Movement of flying units has been improved to avoid any issues while moving a group of flying and normal units at the same time.
    - There was an offset that made flying units have a greater position on Y axis in comparison to the air terrain, with the new Movement Manager in the last update this now poses a problem, therefore it has been removed.

    Again thanks a lot for pointing this out, it led to me investigating a ton of stuff and improving some small details which will have a great impact on unit movement.

    I guess I answered most of this with the above information.

    As for the flying units attack issue, are you sure you have increased the attack range for flying units so that they're able to target ground units?
     
  4. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Please try the following and let me know if it got you the behavior you wanted from the AI:

    - In the NPC Resource component, under Resource Collection Settings, try to increase the "Resource Need Ratio Range", having this higher than 1 means that the AI will only spend resources on something IF it has more than the required amount (which means that the AI will always have resources left after spending some and will not end up without resources). For example when that value is 2, the AI has only 100 wood and creating a soldier requires exactly 100 wood, the AI will be only able to spend that 100 wood if it has 200 or above meaning that it will be forced to collect wood in this case (collecting wood requires resource collectors and this how the AI will create resource collectors before attempting to create soldiers).

    - In the NPC Resource component, under Resource Collection Settings, try to modify the "Default Resource Exploit Range". This defines how the AI collects resource by default (without having any actual need for them at that moment) which guarantees that the AI will always be collecting resources no matter what.

    - In the NPC Army component, under Army Unit Management, try to increase the "Check Army Reload". That field defines how often the AI attempts to create army units. You can also have direct access to that value so you can write your custom AI behavior that (while having that field set to a very high value at the beginning of the game) decreases the that value periodically until you hit a minimum value that you define. This allows for the AI to take care of resource collection, basic building placement and other things at the beginning of the game and once all that's setup, the "Check Army Reload" will have a normal value and the AI will focus back on creating army units.

    - In the NPC Army component, under Army Unit Management, make sure that you have realistic values for both the "Non Attack Units Ratio" and "Max Non Attack Units" which basically imposes a limit on creating units that don't have an attack army (and thus unable to attack or defend).

    You can also exploit other fields in the 3 main NPC components and note the difference in the AI's behavior each time till you get the behavior you want. Any suggestion regarding NPC is as always more than welcome!

    Are you sure that you have assigned the model under the Building Model field in the Building component?
     
  5. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    You can pick boundaries for the camera movement (in the Camera Movement component, under Camera Movement) and not allow your camera to go over the dead zone you chose even though the flat terrain is larger than the main terrain.
     
  6. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    As I was tracing why the Main Obj hasn't been assigned, I have a question: is there a building center (one that has the Border component) in your scene for the faction that's trying to place the building?
     
  7. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Yes for both faction building centers, I noticed that when I enter play mode the game manager removes the faction manger of the faction that's giving the error. I don't know if that's supposed to happen.
     
  8. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Entering playmode directly inside the map scene? Or coming from the single player menu?
     
  9. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Entering the map directly.
     
  10. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Can you confirm it's not happening in the demo scene? I'd like to know if it has to do with the configuration of the building itself or another managing component. Simply try to use that same building that gets the error in the demo scene and let me know how it goes.
     
  11. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    W
    Would it be ok to use the building center from the demo scene? those have all the necessary requisites.
     
  12. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Can you test once using them and once by replacing them with your own building center?
     
  13. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    I get the same result. Could there be something wrong with my faction manger?
     
  14. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    After further looking into this, can you please check the following things:

    - Are you spawning the building by default? If yes, can you make sure it has a valid Faction ID?
    - Can you make sure that all factions that their Faction Manager components set in the scene?
    - Make sure if these faction managers are correctly assigned in the Game Manager?
    - Does each NPC Faction has its main 3 components (NPC Army, NPC Resource and most importantly in this case the NPC Building Placement) in the scene?
    - If all NPC components are present, are you sure they have a valid Faction ID in the inspector?
     
  15. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Yes it s
    Yess it seems i forgot the NPC building Placement, but now im getting the error code:

    Can't find the AI Faction Manager for Faction ID: 1
    UnityEngine.Debug:LogError(Object)
    RTSEngine.NPCArmy:Awake() (at Assets/RTS Engine/AI/Scripts/NPCArmy.cs:163)

    Can't find the AI Faction Manager for Faction ID: 1
    UnityEngine.Debug:LogError(Object)
    RTSEngine.NPCResource:Awake() (at Assets/RTS Engine/AI/Scripts/NPCResource.cs:157)

    Can't find the AI Faction Manager for Faction ID: 1
    UnityEngine.Debug:LogError(Object)
    RTSEngine.NPCBuildingPlacement:Awake() (at Assets/RTS Engine/AI/Scripts/NPCBuildingPlacement.cs:86)

    Can't find the AI Faction Manager for Faction ID: 1
    UnityEngine.Debug:LogError(Object)
    RTSEngine.NPCUnitSpawner:Awake() (at Assets/RTS Engine/AI/Scripts/NPCUnitSpawner.cs:60)

    that's because for some reason when i press play the game manger removes its faction manger.
     
  16. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    The Faction Manager only gets removed if it has an invalid Faction ID. Can you check the inspector of each one of your Faction Manager components in the scene and see if they have a Faction ID that is equal or bigger than the faction slots in the Game Manager?
     
  17. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    I see what you mean I went back to the demo scene looked at the faction numbering compared to the Game manger and I was counting faction id as 1 and stated 1 in the faction manger when I should have started at 0. Thank you for the help, I would like to know if there is a way to increase the map size? I have edited the camera and increased the terrain size but I still cant place buildings outside of the map, there is a map boarder.
     
  18. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Sorry about the confusion regarding the faction IDs, that will change in the next update.

    To re-size the map, make sure to also re-size the Flat Terrain and to re-bake the navmesh in addition to increasing the camera's movement boundaries (under the Camera Movement component).
     
  19. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Thank
    Thank you
     
  20. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Is there anyway I can disable what shows up on the minmap? Also how would I get the minmap to show up in the inspector im try to design the UI around the minmap but that's kind of difficult when you cant see it.
     
    Last edited: Jul 12, 2018
  21. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Selecting the minimap camera will show it in the scene view.
    What would you like to disable on the minimap exactly?
     
  22. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    I'm trying to disable the non walkable terrain on the boarder its just taking up space. Is there a way to get it on the canvas im trying to line it up with all the other UI.
     
  23. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Can you please specify what you exactly mean by the non walkable terrain? Do you mean the Flat terrain? Or the map borders from the demo scene?
     
  24. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    I decided to just make the mininmap larger that fixed the problem. Is there a way to disable the minimap?
     
  25. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    29
    I can confirmed that the units with height >0 or with flyable option activated cannot attack ground units.
    I have pushed the range to 100 and nothing happened.

    On the other side, ground units can attack flying units.

    For the AI part, it is broken on my scene even with your help I can not achieve any valuable behavior but this is not important for now. I will see later.

    My main question of the day:

    What is the correct scale of an environment for your game engine?
    Do we need to have the same scale for buildings like the demo scene?
    Can we increase size or decrease it without problem?

    We are speaking about speed of flying units and youvsay that this is a high speed but for me a speed of 10 is just The base of the dynamic and I need to use faster units... really faster in some cases.
    Same thing for the range of targeting 10 is like shot on feet, 40 medium range, 100 and more begin to be the long range.

    So how is scalable the engine and its components?
     
  26. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028


    Here's a the "flying" archer attacking a unit from the air. The flying units will be fully fixed in the next update (which is pending review). Sorry for the late update but I wanted only to submit this when I make sure everything works as I wanted it to.

    As for the scale of the game engine, you can work on whatever scale you want to. The issue here is not the game engine itself but rather the pathfinding. I'd suggest to increase the stopping distance (which is set to 0.1f by default) in the Movement Manager since this is where the issue of the units shaking is coming from. Units are moving with high speed -> they have high acceleration and sometimes it's so high that 0.1f as a stopping distance won't be enough to detect whether the unit arrived in its destination or not. Try to increase the stopping distance and let me know how it works out.
     
  27. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    You can simply select the minimap camera, and set the viewport's width and height to 0.
     
  28. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,028
    Here's the v1.3.2 update list:
    • Bug Fixes:
      • Rally points have been fixed and can now be used by NPC factions.
      • Fixed a bug that didn’t allow buildings that have an attack component to attack enemy units (Fixed the Tower building in the demo scene).
      • Fixed resource generation in the demo scene.
      • Fixed a camera movement bug that appears when the map has a large size.
      • Fixed Flying Units.
      • You can now choose whether to automatically switch back to the basic attack type after launching another attack type or not from the Multiple Attacks component.
      • Improved the attack object delay: You can now create the attack object and only start its movement after the delay. When created and still in delay, you can also choose whether the attack object will be able to do damage when it’s still in delay or not.
    • New Features:
      • New Task System:
        • Creating tasks for buildings from the Building component has been deprecated.
        • Added a new independent component called “Task Launcher” which will handle creating and managing tasks for both units and buildings.
        • Task Types include: Unit Creation, Research, Self-Destruction and Custom Tasks. Custom tasks are tasks that only trigger events and pass all the task information entered in the Task Launcher.
        • In addition to the delegate events, each Task Launcher can now trigger events independently when the task is launched, completed and/or cancelled.
        • Improved the Task Panel UI management in the UI Manager for better performance.
        • User-Friendly custom editor for the Task Launcher component.
      • NPC factions can now place buildings that required to be placed next to certain resources.
      • Buildings can now be placed in their original rotation (the one set in the prefab Transform component).
      • Added a custom event that’s called whenever an object collides with an object that holds the Selection Obj component.
      • The Unit Animator Controller has been improved in order to have smoother transitions between different states.
      • Added audio clip triggers when a building upgrade is launched and when it’s completed.
      • Added Line of Sight (LOS):
        • When LOS is enabled, the attacker will only be able to attack if the target is in its line of sight.
        • As a reference, you can choose whether the main attacker object or the weapon object (if assigned) will be used to see if the attacker is in LOS of the target or not.
        • You can define how strict the LOS is from the Attack component inspector.
        • You can also choose to ignore one or more rotation axis when calculating the LOS.
        • You can now assign a destruction object + an audio clip that goes with it for units that will appear on the unit death.
     
    jobo22 likes this.
  29. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    29
    Thank you for this solution.
    A simple value of 0.5f solved the issue for my common fighters.

    Happy to see a system of LOS in the new update.
    I'm waiting for the new published version in order to update my version.

    I have some requests which can be done simply I think to enhance the possibilities:
    - allow the converter to convert buildings with a boolean yes/no in the component
    - offer the possibility to obtain resources by capturing neutral resource buildings which generates resources when owned

    One maybe more advanced:
    -> Could you move the option to build in or out border to the building component itself?
    Because, if we want to do a faction with restricted area for the main base but with some advanced warp gate or outposts this is not possible since the option is define for all factions.
    And it would help to create some factions without limits.

    I like assymetric factions and possibilities and this is a good way to develop the gameplay for each faction.
     
  30. MegaCo

    MegaCo

    Joined:
    Jan 24, 2018
    Posts:
    32
    Im getting a movement error:

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index

    IndexOutOfRangeException: Array index is out of range.
    RTSEngine.MovementManager.LaunchAttackLocal (System.Collections.Generic.List`1 UnitsList, UnityEngine.GameObject TargetObj, AttackModes AttackMode) (at Assets/RTS Engine/Units/Scripts/MovementManager.cs:543)
    RTSEngine.MovementManager.LaunchAttack (System.Collections.Generic.List`1 UnitsList, UnityEngine.GameObject TargetObj, AttackModes AttackMode) (at Assets/RTS Engine/Units/Scripts/MovementManager.cs:498)
    RTSEngine.SelectionManager.ActionOnBuilding (RTSEngine.Building HitBuilding, TaskTypes TaskType) (at Assets/RTS Engine/Selection/Scripts/SelectionManager.cs:646)
    RTSEngine.SelectionManager.Update () (at Assets/RTS Engine/Selection/Scripts/SelectionManager.cs:134)

    Its says it had something to do with the stopping distance.