Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity RTS Engine

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

  1. Tegleg

    Tegleg

    Joined:
    Jun 10, 2013
    Posts:
    79
    hello
    im trying to make this work on a touch screen and wonder if you could point me to the right bit of code.

    when i try to create a new unit, for example,
    touch the building and the units appear on the task panel
    touching the unit i want to create makes the panel empty and no unit is created.

    i notice the tool tip does not appear as there is no mouse hover, is this something to do with it?

    thanks for any tips on where to look and what to change
     
  2. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    That's really simple, do the following:

    - Increase the size of the terrain form the Terrain component's inspector if you are using a Terrain object or simply scale/add the tiles you are using as the map. Make sure to re-size the Flat Terrain object as well.
    - If you are limiting the space that the player can view from the main camera (Screen Limit is enabled in the Camera Movement component) then make sure to modify the minimum and maximum screen limits in the Camera Movement component to suit the new size of the map.
    - Make sure to re-bake the navigation mesh.

    I will add this in the FAQ page of the documentation.
     
  3. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Thanks for reporting these issues, I'll check them out and provide a fix ASAP.
     
  4. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    A lot has changed in the RTS Engine with the new update and therefore the way maps are set up changed as well, you might be missing a couple of things but you don't actually notice them.
    I would highly suggest to use the RTS Engine menu editor and choose "Configure New Map" when you're about to create a new map and then simply go from there. That will import all required components to create a new map.
     
  5. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    By makes the panel empty do you mean that the building gets de-selected or only the task panel is empty but the building is still selected?

    As for the tool tip, an alternative would be to have a small info icon near each task that triggers the tool tip message everytime the player clicks on it. That's only a suggestion though.
     
  6. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    I created my map with "Configure New Map", that's how I always make my maps. It still had stuff missing compared to the demo map. I will keep looking to see if I can find the problem. Thanks.
     
  7. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Okay let's break it down one issue at a time.

    You mentioned that you can't move units? Can you check if the units you are trying to move have their Target Position Collider set? (under Unit Components in the inspector).
     
  8. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Yes my units have it. The demo units don't work in my map either. Also, the MvtTargetObject never gets activated when I right click to move a unit, so I don't see anything flashing either.
     
    Last edited: May 18, 2018
  9. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Can you show me a screenshot of your Movement Manager component inspector? I would say the problem lays there.
     
  10. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Here it is. Like I said, when I create the map with "Configure new Map", it doesn't come with the MvtManager, so I had to add it myself.
     

    Attached Files:

  11. Tegleg

    Tegleg

    Joined:
    Jun 10, 2013
    Posts:
    79
    thanks
    yes the building gets deselected.
    as i have a mouse as well for testing purposes, if i position the mouse in the selection box (where the units can be created) then touch the screen (create unit button) the unit gets created.

    is there something that checks if the mouse pointer is over the task panel or something?
     
  12. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Hmm, okay is the Terrain in your scene properly setup? Do the terrain tiles/objects have the proper layer(s) defined in the Terrain Manager component?
     
  13. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    I have attached pictures of what my terrain settings are set to when I create a new map. I have also tried changing the layer of the flat terrain to default, but that didn't seem to change anything. I also tried changing it to Terrain layer, but that just froze unity when I tried to create a unit. I have also tried using a normal Terrain instead of a plane, which is what I want to end up using anyway, but that didn't work either.

    EDIT: I can move the units if I right click somewhere on the minimap. The units move to the right position, and the flashing thing appears on the map, but not in the right spot. I still can't move my units normally.
     

    Attached Files:

    Last edited: May 20, 2018
  14. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Looks like your Terrain plane doesn't have a collider which is essential to detect raycasts. Add a collider to it and see if the problem still happens.
     
  15. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Haha I'm so special, that fixed it thanks! You always give the best support! :) I can place my buildings now also, everything works.
     
  16. cidiego

    cidiego

    Joined:
    Oct 27, 2017
    Posts:
    17
    Excuse my ignorance, but is there a proper way to update my project with the new RTS engine version? I mean, I have downloaded the newest version, then clicked reimport.But now I have lots of errors:

    Assets/RTS Engine/Units/Scripts/AttackObjsPooling.cs(10,14): error CS0246: The type or namespace name `AttackObject' could not be found. Are you missing `RTSEngine' using directive?

    and many other "could not be found" issues. Am I updating it wrong ? Could you please help me ?
     
  17. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    I got quite a few errors as well, I think the best thing to do is delete the old RTS Engine and then import the new version. So you could just delete the whole RTS Engine folder and then re-import the new version. At least that's what I did and it fixed my problems.
     
  18. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    To be honest the best way to avoid any weird issues right now is to start a fresh project. The reasons are the following:

    - So much has changed in the new update and so many components have been deprecated & new ones added.
    - The whole multiplayer code has been re-written from scratch.
    - Movement system has been re-written from scratch.

    I'm really sorry if this has caused any convenience but in order to improve the asset I had to do major changes.
     
    cidiego likes this.
  19. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I would to also point out that I'm currently working on v1.3.1 which will mainly fix some of the issues that were reported with v1.3.0 and add a couple of small new features.
     
  20. cidiego

    cidiego

    Joined:
    Oct 27, 2017
    Posts:
    17
    No, don't get me wrong. You are doing such a great work! You have got to keep it up :) Im just trying to learn.
    Thanks for your help!
     
  21. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Thanks for the kind words, let me know if you have any further issues.
     
  22. cidiego

    cidiego

    Joined:
    Oct 27, 2017
    Posts:
    17
    I actually have two things to comment in an attempt to contribute:

    Being able to set a building rally flag over a resource ( thus making the workers automatically go and take them) would be very convenient. This is a standard feature in many RTS games.

    Moreover, moving the arrow next to the border wont move the screen if that border has the minimap canvas nearby. I find it kind of frustrating.

    I have to say that the new version is much cleaner and easier to understand from a noob's perspective. (At least the new demo map) Very good work!
     
    Last edited: May 23, 2018
  23. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Will be added in the next update.

    Hmm, this shouldn't be happening, looking into it!
     
  24. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    So there are a few things that I think should be fixed. First, I have a couple buildings that I checked "Place Near Resource", so they can only be placed next to a certain resource. It works fine for me, but the AI players don't place it next to the resource, they just place it wherever. Second, when the AI builds units, they get built on top of each other so sometimes it looks like there is only one unit there when really there are more. I noticed that the AI player doesn't use the "Go To" position, I think activating that would solve the problem (assuming you made it in a different spot than the spawn position). Or just move a unit if it's in the way of a unit that needs to spawn. And lastly, the area damage doesn't work. I have a unit that does area damage, and I can see the damage effects, but the enemy units don't lose any health. So hopefully that can be fixed easily.

    Oh and one other thing is that the units rotation damping doesn't seem to do anything when you command them to move. They will rotate with the proper speed if they are just sitting there and are turning to attack, but if you order them to move they will turn around super fast.

    P.S. Could you make a custom delegate for when units collide with each other? I want to make it so that my tanks can squish infantry like in the old C&C Red Alert game haha. And with that, would there be a way so that if I command a tank to move through an infantry, my tank won't try to move around it? Thanks! Sorry for all the questions! :)
     
    Last edited: May 27, 2018
  25. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Really sorry that you're having these problems and thanks a lot for reporting them.

    These issues, except the area range attack bug, will however be fixed in the next update since I already submitted v1.3.1. I would ask you to ignore those for the moment as they are not game-breaking issues and in two weeks or so when v1.3.2 is available, they'll be fixed (should be also fairly easy to fix). The delegate event will also be included in 1.3.2.
     
    jobo22 likes this.
  26. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Update v1.3.1 has been recently submitted and should be available in the beginning of this week, here's the update list:
    • Bug Fixes:
      • Fixed a bug when double clicking on units.
      • Fixed a bug that registers a pre-placed building in the map twice.
      • Fixed a bug that deselects selected units after placing a building.
      • Fixed a bug in the Input Manager that makes the Input Manager fail to recongize dead units/buildings.
      • Fixed a bug that stops the unit from triggering the attack animation when the unit has more than one Attack component attached to it.
      • Fixed a bug in area range attacks in multiplayer.
      • Fixed a bug that blocks builders from moving towards the buildings to construct them.
      • Fixed units’ rotation on movement.
      • Fixed creating new maps from the RTS Engine menu editor.
    • New Features:
      • Added Destroy Time for buildings.
      • Free Buildings in the map now must have Placed By Ddefault enabled in order to spawn fully built, otherwise they will only spawn in construction mode.
      • Added an option in the Builder component to allow builders to construct free buildings.
      • Minimap cursor now changes its position after doubling click on a teleport to highlight the camera position change.
      • Added a field in the Selection Obj component for units and buildings only that, when enabled, allows only the unit/building owner to select that unit/building.
      • APC:
        • Instead of a listing the units that aren’t allowed to enter an APC, it’s now possible list unit codes and choose either to accept those units only or to accept units except the listed ones.
        • Added the options to allow the APC to eject all units with one task, eject one unit only each or have both options enabled at the same time.
      • Instead of a listing the units and buildings that can’t attacked by a unit/building, it’s now possible to list unit/building codes and choose either to allow the attacker to attack those units/buildings only or to attack all units /buildings except the listed ones.
      • Added a field in the Unit component that, when enabled, makes the unit invincible and allows it to avoid damage.
      • Added an audio clip trigger that is played when the unit is moving.
      • Added the ability to set the a building rally flag over a resource/building (thus making the workers automatically go and collect the resource/construct the building).
    For the full list of changelog, please visit: http://soumidelrio.com/assets/rts-engine/changelog/
     
    jobo22 likes this.
  27. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Ok thanks! And yes they are not game breaking bugs so it's definitely not a rush! The new update looks great! And thanks for adding the collider custom delegate in the next update for me. :)
     
  28. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    So a couple more things I'm having issues with...First the attack component isn't working on my building, I have the "attacker" set to building and everything else is set up like I have it for the units, which attack just fine. I don't get any errors, the attack weapon doesn't rotate at all, and the building never shoots. Second, I'm just wondering if there is a way to keep the buildings rotation when you place it. I set my buildings prefab to be rotated about -145 degrees on the y axis so that they face the camera, but when I try to place them they always just place at 0 degrees on the y axis. I can change the models rotation and it will keep it when I place it, but then the buildings model won't match up with the colliders on the model. I looked through the code of the "Building Placement" script and think I found where the buildings rotation is set when placing, it was set to Quaternion.identity, I tried changing it to a new Quaternion (0, -145, 0, 0), but then when I tried placing the building it was always set to 180 degrees on the y axis for some reason. I tried changing the -145 to other numbers but it always was 180 when I tried to place it. Thanks! :)
     
  29. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I will look into it and provide an answer ASAP.

    Are you setting the transform.rotation to (0, -145, 0)? if yes that's not really valid. You should change the transform.eulerAngles to (0, -145, 0) instead.

    Check this out: https://docs.unity3d.com/ScriptReference/Transform-eulerAngles.html

    Thanks yet again for pointing out the bugs. A lot has changed with the 1.3.0 update and therefore some unexpected issues have appeared. Thanks to everyone for their patience and their continuous support for the asset.
     
    jobo22 likes this.
  30. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Yes I was using transform.rotation, I looked at link you sent and changed it to that and now it works great! Thanks for all the hard work you put into this! :)
     
    OussamaB likes this.
  31. generalhak

    generalhak

    Joined:
    Apr 20, 2014
    Posts:
    28
    hi, nice asset and really good work , i played the demo :
    1- knowledge building dosn't give any knowledge !
    2- there is no local avoidance so units pass through each other ! (this one really keep me from buying this asset)
     
  32. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Will be fixed in the next update.

    Since Unity's pathfinding local avoidance isn't really that good and it has created a lot of problems in the past, the new approach for moving units now is to let them move through each others when crossing paths but rest assured, two units will never occupy the same final position.This is of course alwqys subject for improvement.
     
  33. generalhak

    generalhak

    Joined:
    Apr 20, 2014
    Posts:
    28
    wow thanks for the fast answer !
    i know that and that's good but in a real strategy game local avoidance is necessary
    units have to never pass through or overlaps with buildings and other units
    in the demo maby this is fine but if you replace the humans with tanks and big units then it will be really annoying and unrealistic , i know local avoidance with lockstep is really hard to code ,but its the only thing this asset don't have.
    because with that this asset will be perfect. so please add this, thanks
     
  34. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    I know, it's really something that I want to add to the asset as well but I unfortunately cannot give an exact at when this feature will be added so yeah, thanks for the kind words.
     
  35. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Hi, is there some way I can make it so that my units can have different movement speeds? So like sneak, move normal, and move fast? I would like to be able to choose which speed I want the unit to move at from the task panel. Right now there is a move task, but how could I make two more move tasks, one for sneak, and one for move fast? I know this is fairly game specific and you probably won't implement this yourself, but if you could point me in the right direction on how to add it myself, I would very much appreciated it. Thanks! :)
     
  36. Mientas

    Mientas

    Joined:
    Jun 1, 2018
    Posts:
    1
    How old are u mate :D ??
     
  37. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    You should be able to have access to both the "Speed" attribute in the Unit component and the speed in the Nav Mesh Agent component attached to the unit. That way you can manipulate the speed to your lickings.

    Regarding adding tasks, I recommend you to go through the UI Manager component and follow how built in tasks are created and then go from there. Start by checking the "UpdateUnitTaskst()" function and build from there.

    I was considering adding a way to allow you to build your own tasks and I guess it's going to happen soon.

    I guess this is not really related to the RTS Engine, so yeah.
     
    jobo22 likes this.
  38. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Ok thanks!
     
  39. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    97
    This point should be your priority since this is a really issue when you move your army and a single shot of an artillery can kill all units in the smallest AoE.

    This behavior is a really hard point for balance.
    It is impossible to consider any unit using a weapon with AoE in this case.
     
  40. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Sorry for the late reply but could elaborate how would that exactly presents a problem in this case? I'd like to tackle this problem and go from there.
     
  41. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    97
    When you move your army, all units can be merged on a same location according to the path. There is no collision detection with your solution.

    If a unit with a AoE strikes the units at this moment, all of the units are dead or heavily damaged.
    The AoE units are overpowered, even with a small radius.

    In all RTS a group of units move according to their collision box, so no merge effect and if a AoE strike occurs on the group, only some units are damaged.
    This is a way for a large group to survive of a battery strike with a quick assault.
    If the group is too small, artilleries win.

    In your case, artilleries always win.
    With flame thrower it is even worse if they ambush a moving group.
     
    OussamaB likes this.
  42. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Got it, I will at least look for a temporary solution to avoid this issue by the next update and will soon start working on my own deterministic pathfinding solution but that'll take some time. Thanks a lot for taking the time and explaining this!
     
  43. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Hi, so I have a couple questions/requests. First, in the changelog you say you fixed units rotation on movement, but my units still rotate very quickly when I order them to move. Not sure if the bug fix you did was for that problem or another rotation bug. Second, you also say in the changelog that you added a audio clip for when the unit is moving, but I don't see anywhere for me to put one. For one request I was wondering if you could add a destruction object and audio clip for units just like you have them for buildings. My other request, could you make it so there is the option to only let a unit shoot if it or its weapon object is looking at the target unit. So for my tanks, they would only shoot if their turret was aimed at the target, that way they don't shoot when they aren't facing the target and the bullet goes sideways towards the target. Thanks!
     
  44. OussamaB

    OussamaB

    Joined:
    Feb 8, 2013
    Posts:
    1,470
    Before the fix in the latest update, units were rotating quickly on movement but once they reached their destination they rotate back to the default rotation. And that was the thing I fixed, I'm really sorry if you expecting a fix to the the issues you mentioned but this can modified from the Nav Mesh Agent component of each using along with the movement acceleration and other settings. Let me know if modifying the rotation acceleration fixes your problem.

    Assigning the audio clip isn't visible from the Unit inspector because the Unit Editor hasn't been updated, PM me your e-mail and invoice number and I'll send you the fix which will be of course included in the next update.

    Awesome suggestions as always, thanks a lot, you'll see those implemented soon.
     
  45. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Ok thanks for clarifying the rotation you fixed, that was a great fix anyway. I changed the values in the navmesh component and was able to get the rotation pretty much how I want it. I had to comment out a couple lines in the Unit script that was automatically setting the angular speed and acceleration to very high values automatically, but that was very easy to do. Thanks for helping me figure it out. Also, don't worry about sending me the movement audio clip, I can just wait for the next update, but thanks for offering. And I'm glad you like my suggestions, I couldn't come close to what I'm trying to make without this asset! Thanks very much! :)
     
    OussamaB likes this.
  46. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    97
    What is the best way to build a second map?

    Should I duplicate the first one and modify the environment or there is a way to hide the first one and only work with the second one or something like that?

    Secondary question: we can only define one building for resource collection or each resource can have its specific building?
    I only see one entry for the resource building in the Capital faction manager.

    Edit : I have an additional question also :
    When I look at the demo scene, I don't see any units or buildings except the capital of each faction.
    And in the tree of objects, I don't see any references to units and buildings and also how to define which building needs another etc...
    Where and how (with an option?) all buildings and units are hidden?

    On my scene I have each time the version of a unit and/or a building to define it.
     
    Last edited: Jun 14, 2018
  47. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    Hi, is there some way I could make an accuracy setting so that sometimes the bullets will miss? I tried adding to the target position a randomness but the bullet still always went straight at the target. Then I tried adding some force to the rigidbody on the bullet to make it go a little off target but it also went straight at the target. I know most RTS games don't have it, but my game is a little different and I would like the bullets to miss the target sometimes, especially the farther away they are. Also, could you make it so that if there is multiple attack components, both can shoot at the same time. I noticed if I enable the "Multiple Attacks" component while I'm playing, then they both shoot at the same time. But if I have it enabled and then go into play mode only one will shoot. And I couldn't use multiples sources on the same attack component because one of my bullets reloads much quicker than the other, so I had to have two attack components so I could have two different reload times. And what about making it so that there can be a burst, like 5 shots in a row and then reload? Sorry for all the questions! Thanks! :)

    EDIT: I actually got the accuracy to work with the rigidbody by adding forces, I just had to uncheck freeze positions.
     
    Last edited: Jun 16, 2018
  48. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    97
    I have another problem: I started from scratch a complete new scene.

    I have managed to spawn units, make units to wander, I can click on a building or on a unit and for example on each button on the UI, I can select a unit but I can not move the unit, and the click on the minimap to move on an area doesn't work.

    What is the item I forget when I start with a cleaned scene?
     
  49. jobo22

    jobo22

    Joined:
    Dec 1, 2016
    Posts:
    83
    I had this problem earlier, make sure you have a box collider on the "Flat Terrain" object. At least that fixed it for me.
     
  50. Seling

    Seling

    Joined:
    Apr 26, 2018
    Posts:
    97
    Thx for the idea.
    I have added a box collider and see some progress but now I'm exactly in your first status of issues.
    I can navigate on the minimap and move view by minimap.
    But units only respond by a click on the minimap - the click on the terrain has not effect.

    I have compared your pictures of managers and I have the same things.

    Could you show me a picture of your box collider added to flat terrain if I missed something? This could be very helpful.

    Some things are missing during the creation of a new map from scratch and it is a bit hard to solve these issues.