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

RTS Toolkit

Discussion in 'Assets and Asset Store' started by chanfort, Jun 6, 2014.

?

Which phase of RTS Battle Simulator need improvements?

  1. search

    40.0%
  2. approach

    31.4%
  3. attack

    57.1%
  4. self-heal

    22.9%
  5. death

    14.3%
  6. rot (sink)

    22.9%
Multiple votes are allowed.
  1. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    So, I started to use A* Pathfinding Project towards the creation of add-on. Here is just a sneak peak of what A* helps to achieve:
     
    elias_t likes this.
  2. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Here is another sneak peak for A* usage: 2k archer units while standing gives ~40 FPS and while moving ~20-25 FPS performance (in Editor). Most of CPU power is eaten by local avoidance in very crowded areas.
    It also looks nice to see such high number of units working with the environment. And as I started to use standard shader for 3dSprites, they all now cast shadows, what makes these armies to look even better.
    Screen Shot 2016-04-18 at 02.24.07.png Screen Shot 2016-04-18 at 02.25.19.png
     
  3. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
  4. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    The new town development AI looks very promising. Here are two time-lapses from the distant and close view:

     
  5. Scimajor

    Scimajor

    Joined:
    Feb 27, 2013
    Posts:
    3
    I purchased your asset. It looks great but the tutorials are so out of date that nothing works as shown in them. I tried to follow the example in the documentation but I get null reference exceptions when I try to verify camera operation at step 6 in the advanced setup. I'm assuming that because nothing is assigned to "terrain" or "RTSM" in the RTS Camera script in the tutorial. I assigned the terrain to the terrain parameter but there's nothing to assign to the RTsm parameter. I tried to make an empty object and assign the RTS Master script to it, and then assign the empty object to the RTsm parameter on the camera but that didn't help anything.

    Do you have any updated tutorials that use the latest version of your asset?
     
  6. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Hmm, interesting. Yes, if you start to attach scripts manually, they won't work properly, as there are several dozens of references between all scripts. The easiest way at the moment is to use RTS Compiler to compile it from scratch. I was recently started to look over the problem by using static references for scripts, which should add more flexibility. It should be as easy as dragging and dropping prefabs in the future.

    Another thing is which exactly video are you watching and what you are trying to achieve?
     
  7. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Long awaited "life-easying" update is coming up, when the whole system can be just dragged and dropped as a single prefab in the empty scene:
     
  8. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Long awaited battle demos finally made its way to the trailer:

    and its related tutorial, where I show how I trace battle intensive areas, recording and editing videos to get it in the form of a trailer (i.e. you can use it for getting started to make your own trailers for your games):
     
  9. titifluki

    titifluki

    Joined:
    Jan 9, 2015
    Posts:
    23
    Hi Chanfort...

    I get this errors in uRTS 5.0 (unity 5.2.4)

    Assets/uRTS/Standard Assets/Utility/ForcedReset.cs(3,19): error CS0234: The type or namespace name `SceneManagement' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    Assets/uRTS/Standard Assets/Utility/TimedObjectActivator.cs(4,19): error CS0234: The type or namespace name `SceneManagement' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?
     
  10. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Hi titi, long time :) . It seems to be coming from standard assets, not from the uRTS itself. So I guess it's safe just to delete these two scripts (ForcedReset.cs and TimedObjectActivator.cs) from Assets/uRTS/Standard Assets/Utility/ folder. I don't think there is anything using them.

    You should also use uRTS 5.0 with Unity 5.3.4 rather than 5.2.4, as some features might be not working with 5.2.4 correctly.
     
  11. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    A massive recent update has just been released. It contains reworked main gameObject in a way, that devs now can simply drag and drop entire uRTS system in their scenes, more categorised its setup (with main categories as RTS, environment and UI). UI has been also completely reworked, now designer can simply modify UI elements, which are written in Unity v4.6 style, in order to achieve their needs.

    The biggest thing is completely rewritten documentation, which is over 100 pages (it can be also found in my website www.urtsstudio.com by clicking "documentation" button for uRTS Toolkit). Documentation has in depth explanations as never before. I also wrote it in a more easy to read style than previous documentations. There are also ~80 figures there in order to see how things are set. I am also open for suggestions, corrections, comments about this documentation. Hope it will help to better adapt uRTS in your projects and use its functionalities.

     
    Last edited: Sep 21, 2016
  12. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Hi, congrats on a great looking toolkit which you've built up so far!
    I've just purchased it, as I'm trying to learn the basics of unity within a RTS context.

    Overall loving it so far... however upon playing the armies scene, I've noticed that there is a very annoying flickering going on where some of the objects disappear and reappear between updates. It gets more noticeable the more objects there are in the scene, since everything slows down visibly.

    Reading back through the forum posts, this was reported a while back, but got resolved ? Just wondering if anyone else is experiencing this issue?

    Keep up the great work and looking forward to further updates.

    Edit: Just checked some of the short clips on your "Tales of Eightrivers" facebook page and I can see that the same flickering is going on there too... so any idea what is causing this and any chance it can be fixed ?
     
    Last edited: Sep 25, 2016
  13. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Thanks for a question. I was looking for this flickering affect for a while, but there might still exist some artefacts. I suspect it is something mostly linked when switching between real 3d models and 3dSprites. I suspect that there is probably one update passed when disabling model and enabling sprite. A good set of questions here could be:
    1. When flickering is actually happening?
    2. Is it happening for all units at the same time or only for units in particular areas?
    3. How long it takes between disappearing and reappearing - is it more like fast blinking or slow one?
    4. Are there all type of units flickering or just particular types?

    I think there is possible to avoid this flickering - if you have very low poly models, you can switch sprite distances to a much larger values or even disable 3dSprites usage, i.e. always use 3d models if possible.
     
  14. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    I think it's actually happening all the time, ie it's an inherent factor of the design. It's just that when there are only a few models/sprites in the scene, the update time is fast enough that you barely notice. When the scene gets busier it becomes more noticeable.

    No it's not all units at the same time, it seems to be specific units at random

    See my comment above regarding it being dependent on the scene complexity. It doesn't seem to be cyclic or repetitive, more random

    It seems to happen for all types of objects, not just 3dsprites but also 3d models too. And not only upon transitions, but also for 3dsprites and 3dmodels which are not transitioning

    Yes but this kind of defeats the purpose of the 3dsprites system for RTS usage, which you have put so much effort into!

    I'm not so familiar with Unity, but it seems to me to be something in the rendering approach. Do you know if the model updates run asynchronously to the model rendering ? ie is it possible that the model might get rendered whilst a position/orientation/animation update is in progress ?

    To pinpoint you at part of your scene which shows the flickering in action, look at the following clip from the time position shown:

    Flickering.jpg
     
  15. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Very interesting point. In that case previously it was different problem, as it was flickering when switching from 3d models to sprites. That one got fixed, but this one seems to be random, which I didn't noticed since now.

    It would be interesting to try with units, which does not use 3d sprites: these units are at the moment riders, catapults and ballistas. If there are created several hundreds of these units instead of knights, does flickering appear?

    If that's related with 3d sprites, you could use 3d models just temporary, as finding bug may take a while. If the bug would appear to be coming from Unity's side (i.e. some rendering artefacts), it may take much longer to create proper scene with clearly showing bug, send a bug report, and get it fixed.

    Other questions could be:
    1. Does flickering appear when camera moves?
    2. Does flickering appear when unit moves?
     
  16. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    My suggestion is that you are in the best position to check these questions out using some of the setups you have video'd in the above clips. If you play the clip above at the frozen timeline position, you should hopefully see the issues I'm talking about which might give you further clues about what is happening?
     
  17. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Thanks for the feedback. I will continue hunting the bug. If you notice something interesting, feel free to post.
     
  18. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Did you come across anything yet ?

    I did a few tests where I disabled all unit animations and movements, and ended up with a situation where the first set of armies that were spawned were just standing still (no movement, no animation). The switching between 3d models and 3d sprites was still working nicely. I would say that the flickering had gone.

    Spawning further armies which also did not move and were not animated then brought the flickering back again, but only with the 3d sprites, not the 3d models.

    So I definitely think there are some issues going on with the 3d sprites, and wanted to ask about the design approach using the particle system. What are the conditions when particles are added and removed, because I suspect the flickering that I'm seeing is related to when some particles are destroyed and new ones created. In a static scene with nothing moving or animating, are all particles also static, or are particles still being created/destroyed every few frames/seconds ?

    I think the other issue going on is some updates being done using StartCoroutine, eg UnitMoving but haven't managed to prove this yet.

    Hope this is of use, if you can give some info about the lifetime/behaviour of the particles in your 3d sprite system, this could throw some more light on it.
     
  19. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Wow, these are very nice tests :) Unfortunately didn't checked it yet myself, as I was recently working on implementing carving of procedural rivers on the terrain in uRTS. I am planning to look at this problem in upcoming weekend.

    The way particle systems works is that there is separate particle system set for each rotational level. If model rotates or moves, or camera rotates or moves, unit rotational index is changing. This gives that unit is being moved from one particle system to another (should be AddAndRemoveParticles() in PSpriteLoader.cs). If nothing moves, particles should not be moved between particle systems. As for animation, particle remains in the same particle system and only particle startLifeTime and lifetime are updated to start a new animation cycle. If animation is switched (i.e. movement is triggered and animation switches Idle > Walk), then particle is also moved from one system to another (but this time AddParticleFromUnitPars, ForceRemoveParticle functions should be used). I suspect that some of these functions skips one update (i.e. particle could be removed from one particle system and only added to another system after one frame).

    A very easy example could be to unset any other nations, that they would not spawn any units, and use QuickSpawnArmies to spawn one or another type of units on player nation. That should be quite fast, as it's just single click to spawn N units in a circular radius around player nation centre. They will be all using Idle animation, but that does not add or remove particles (they are staying in the same particle system).

    Another thing which could be useful is to put some Debug.Log() statements with possibly time.Time printouts in adding and removing functions to see if particles are not moved between particle systems.
     
  20. ringmod

    ringmod

    Joined:
    Oct 8, 2015
    Posts:
    6
    The doc doesn't work OOTB with the latest Unity, FYI. Some of the scene names have changed. Thanks!
     
  21. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Could you tell please which scene names have changed and which pages of doc you are referencing?
     
  22. ringmod

    ringmod

    Joined:
    Oct 8, 2015
    Posts:
    6
    The very opening paragraph.. It says to open scene->4rivers, but that doesn't exist. I think it's called "Armies" now?

    upload_2016-10-3_21-17-40.png
     
  23. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Hmm, are you sure you are using the new version of documentation for uRTS v5.1, which is published from 08/09/2016 ? You can find this version also here:
    https://chanfort.github.io/docs/uRTS_doc.pdf

    I searched "4nations" and "4rivers" and there are no these keywords in the new version of documentation. New documentation should be also 112 pages long while the old one (i.e. v5.0) is just 35 pages in total.
     
  24. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    So it seems like I found how to fix this flickering. I should soon start recompiling and updating demos and published ToER games with this fix, as well as uRTS.

    The problem was that positions on particles were set sometimes differently. The fix is to use old particle position instead of using transform.position from gameObject when moving particle from one system to another (ForceAddParticle() and ForceRemoveParticle() functions in ParticleSystemNode class). The tricky part here is that before passing that position to adding function, particle needs to be found in the old system and its position stored in Vector3, which then can be passed into ForceAddParticle() function. Another way (which I did) is to merge ForceAddParticle() and ForceRemoveParticle() into a single function (lets say ForceAddRemoveParticle()) - then old position will be in the same function as the new one, which needs to be set. This way it does not need to pass any positions as everything stays in enclosed single function.
     
    Last edited: Oct 7, 2016
  25. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Great! Thanks for searching it out and I'm looking forward to the fix

    For my curiosity and lack of unity knowhow, why do you switch particles between different systems based on their orientation etc? Why not just a single particle system per unit type where each particles position, orientation and animation are adjusted each frame? I'm sure there's a very good reason....
     
  26. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Each particle system can have only it's own particles defined by sprite sheet. So yes, different systems are made for different animations and rotational levels. I.e. one system is for idle animation, another for walk animation (there is only one animation texture, which can be used on a particle system). So walk animation can never appear on a particle system which uses idle animation texture sheet. Screen Shot 2016-10-08 at 10.48.39.png
     
  27. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Ahh, got it.

    Could it be possible to use a very large texture that would include all animations for one unit, or perhaps a same height texture but four times wider to get all poses in?

    Or reduce the size of a single pose, after all the 3D sprites are only shown at distance...?
     
  28. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    It might be possible, but there are limits in final texture resolution (I think largest textures in Unity can be around 8k x 8k). It can be also more efficient to use smaller textures and keep the ones which are not used as disabled. It needs a lot of testing to find out which configuration is most efficient. However, moving particles between systems is not very frequent operation and is quite lite. It also seems to be working now correctly.

    There would be still movement between systems needed from different rotational levels, i.e. there are 6 vertical levels and 12 horizontal, what makes 72 particle systems to be allocated just for a single animation. As there are 4 animations (Idle, Walk, Attack and Death), there is 288 particle systems set for a single unit model. Most of them, which are not used are inactive and only a few of them (which are in use) are activated.
     
  29. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    288 is indeed a lot of different particle systems for each unit, I had no idea there were that many!! So for 4 unit types that's over 1000 particle systems! Somehow it would be nice to optimise for even more performance, but I don't have a better idea at the moment.
     
  30. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    I didn't noticed at the moment that 3dSprites would cause performance problems - the down side comes with the point that there are over 1000 texture sheets coming here, what is quite a big load on memory (you can check in profiler memory section when playing the game in Editor - there are over 1000 textures loaded). This is why I set less popular higher units, such as catapults, ballistas and horseman's to use LODs instead of 3dSprites.
     
  31. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    So the asset has just been updated. Flickering should be gone now. However, if there is something still visible, post details.
     
  32. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Great, many thanks for nailing it!
    I'll pick up the update over the weekend
     
  33. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Rivers and the sea has just been added into the new version of uRTS:

     
  34. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    uRTS will now support usage of SpeedTree models (including chopping them):
     
  35. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Well I've updated to the new version but unfortunately have to tell that the flickering is still happening within both the 3dsprites and occasionally the 3dmodels. Also fairly regularly the whole shadowing flickers for a frame. The search continues...

    The new rivers, seas and speed tree features look great, many thanks for bringing these new features to the toolkit

    Edit: See below - I wasn't running the latest asset version! Flickering has gone!
     
    Last edited: Oct 16, 2016
  36. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Hmm, interesting. Could you make a short video then to see where flickering happening? Couldn't see it again :)
     
  37. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    OK will do...
     
  38. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Update:
    I updated Unity to 5.4.2 in order to get the latest Asset version 5.2
    After doing this, the first impression is: Flickering has gone !
    Brilliant!
     
    Last edited: Oct 16, 2016
  39. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    The rendering pipeline has just got a revamp:

    Special thanks to FrozenEmpire for helping to find flickering issues.
     
    elias_t likes this.
  40. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    That's a great update in my view! Instancing is a well proven method of efficiently rendering hundreds or thousands of duplicate meshes, and I'm pleased to see that you've been able to integrate it into this next version. Well done! When do you think it will become available in the asset store... ?

    A couple of other observations/thoughts that came to mind whilst watching your latest video:

    1) The 3d models seem to be positioned slightly above the terrain rather than ON the terrain; this leads to gaps between the models feet and their shadows... you know I have an eye for visual perfection ;)

    2) For the furthest LOD level of the 3d models, would it be possible to just have a simple quad/billboard/sprite with a static render of the model. At far distance, I doubt it would matter that the model is not animated, or not even the correct rotational level, having just a distant quad could be enough. Then you might get even more performance through batching the billboards as well and maybe even achieve 15000 units :)
     
  41. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641

    Thanks. I will probably update it on the Asset Store after Unity 5.5 is released, which is expected to be some time in November. So probably within several weeks. During this time I will continue to check if everything works as expected, as well as writing new updated things into documentation. There will be also a few new features as well - I am currently working on in game controls menu, where player will be able to chose which keys to use for camera movement, etc. Also planning to make graphics and quality setting available to change in game (i.e. player could switch himself between different shaders, such as standard and instanced). However, I should update demos and ToER game before updating in Asset Store.

    1) Yes, I agree, they are slightly above the terrain. Good point, I will continue checking what's going on (this one could be relatively easy to fix) :)

    2) You are probably right, for these very distant models animation and rotation may not matter very much. However, it's worthwhile to check. I guess it could be dependent on a model and animation. Symmetric models, such as knight and archers may be perfect with a single static billboard. On the other hand, non-symmetric models, such as horses, it may sometimes look a bit weird if switching between LODs, horse's head would appear in the opposite side :) . As for animations, it's also similar - some animations, like Idle probably does not need lots of frames even for high resolution LODs. But other animations (like "Death", where the whole model falls on the ground), may look weird as well.

    Going towards larger numbers, I guess rendering is solvable part. But it needs to check navigation and especially local avoidance, which becomes quite expensive when going above 1000 - 2000. Currently Unity's built in navigation does not allow to do many tricks. A* Pathfinding Project is much better here. I am also looking forward what will bring Unity's Navigation bake API update (probably in upcoming months).
     
  42. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Just started to work on bringing more controls for available for in-game mode (for player) rather than just using them in editor. First of them are menus for RTS and RPG camera in-game controls:

     
    Last edited: Jan 3, 2017
  43. CavaleriDK

    CavaleriDK

    Joined:
    Mar 9, 2016
    Posts:
    2
    Hi C, just a quick question:

    Your Rivers class contains this call on ln 93
    UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();

    but it cannot compile into a build since it's Editor specific. Would it be safe to remove this bit or do you have any alternative using Resources.UnloadUnusedAssets() instead? Garbage collecting is a rather new subject to me.

    Thanks!
     
  44. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Oh, I probably forgot to put compiler derivatives around this. Just put
    Code (CSharp):
    1. #if UNITY_EDITOR
    2. UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();
    3. #endif
    And it should work.
     
  45. CavaleriDK

    CavaleriDK

    Joined:
    Mar 9, 2016
    Posts:
    2
    Great thanks! I had it commented out without any problems, but wasn't sure if it had any impact on performance.
     
  46. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    This part (and some other ones) are not running on runtime, so when using compiler derivatives, it doesn't go through compilation. On the other hand, this is used when generating terrain in Editor, so if compiler derivatives are used, then it allows to use this function.
     
  47. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Continuing to improve environment. This time implemented automatic way to detect cliff-beds and so now rocks are placed just bellow cliffs.
    Screen Shot 2016-11-11 at 10.19.09.png
    There is also added in-game Graphics settings, where player has more controls. I.e. the lake in the above picture used refractive water shader, which has been switched from this in-game Graphics settings menu.
     
    Last edited: Jan 2, 2017
    FrozenEmpire likes this.
  48. FrozenEmpire

    FrozenEmpire

    Joined:
    Sep 10, 2016
    Posts:
    96
    Looking good ;)
     
  49. Don-Megel

    Don-Megel

    Joined:
    Dec 4, 2016
    Posts:
    16
    I am very interested in purchasing your system but I had a couple of questions:

    Can it support gun powder units? I assume just increasing the speed of the arrow is not the correct course of action.

    Will it work with different terrains such as are created using Gaia?
     
  50. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    641
    Do you mean cannons (as gun powder units) ? If so, I guess you can start by just increasing speed of the arrow. You can also add some smoke trails, i.e. look at fire arrows - they have some particle smoke trails. You can also try to implement line renderer trails for smoke. Do I miss something here?

    I am looking into Gaia myself. Should be not very complex. I would probably start in a following way:
    1. Create Gaia terrain which you want.
    2. Import that terrain (with all needed assets) to uRTS project or vice versa (e.g. import uRTS into Gaia project).
    3. Import Gaia generated terrain into uRTS main scene.
    4. Set in GenerateTerrain within uRTS updateMode to "Do not update".
    5. Bake Unity navigation on your terrain.
    6. Enjoy! :)
    However, it will be baked terrain (not the infinite one).

    You can also practice a bit with uRTS free on terrains, I think it should work quite nicely there.