1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

uRTS: toolkit

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

?

Which phase of RTS Battle Simulator need improvements?

  1. search

    50.0%
  2. approach

    36.4%
  3. attack

    59.1%
  4. self-heal

    22.7%
  5. death

    18.2%
  6. rot (sink)

    22.7%
Multiple votes are allowed.
  1. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    Hi chanfort. Thanks for the detailed reply.

    The 2 main origins of overhead I believe are the many sprite manager rearrangements and the kdtree search functions.

    As I understand you have a different material for each angle for each pose? Perhaps all poses for all angles could fit in one sprite atlas?

    Also perhaps more then one spritemanager should be used(?) because the sprite manager has to iterate everytime thousands of sprites.

    The kdtree function could be written in c++ and make an optimized lib. I will try it and see if there is some difference.

    About the formations:

    1. They are very useful for any kind of strategic game.

    2. You could treat each formation as a unit and so the battle search functions would eat up a lot less resources. When needed local (inside the formation) searches can be made.
     
  2. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Hi JamesArndt, thanks for question. When you run the simulator, it generates gameObjects. These gameObjects has attached sprite scripts. So you can make that sprite script components would be disabled. On the other hand you can attach mesh renderer to your gameObjects within your script. It does not deal anything with battle simulator script. So in short terms, it is quite easy to switch to animated meshes.

    I was using meshes with about 300 - 500 polys at the beginning and the problem started to appear with batching - there were no saved meshes by batching. This limited my usage of meshes to 100 - 200 units, and I noticed that it did not depended on polys.

    If you would check Facebook or any other demo, you can see that you can select multiple enemies and they are highlighted with selection marks. If you right click on free area, all your selected units would start to move. But the group only exists till you starting to select other units. I am looking forward to save groups, that it would be possible to go back to previously selected groups. But it will be much easier with Unity 4.6 GUI, as I will sort out menus and buttons. Currently there are no menus and buttons, so I need to press keys in keyboard. I don't want to end up with keyboard asset, so looking forward to see Unity 4.6, while doing other big things, like optimisation, Facebook integration, maybe multiplayer at some point.

    I was basically using separate models with different weapons, as my whole models are on single mesh. So if you have just several weapons, you can start to export them as different models. You can also switch between models when needed, but it is not implemented in the system.

    I am more working towards medieval style, so you will probably need to design your 1800's styles yourself :)
     
  3. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Yes, it's true - different materials are used for different angles. But animation poses are taken from the same material. You can check for example for knight/idle what materials are used in Assets/Resources/3dSprites/knight/Idle/mat directory. They are linked to png pics, like these ones:
    knight_Walk_1_8.png
    for each rotational level are used separate images.

    I am not sure about splitting sprite manager - I noticed from some tests that it's faster to run one large loop over all thousands of sprites, than to run separate coroutines onto each unit.

    Do you know any good docs about these sprite atlases, as I was unable to find out how they actually work?

    Kdtree is another interesting point - one of my colleagues is currently working to write add and remove nodes algorithms, which should make whole search algorithm more efficient and avoiding many un-needed searches. By the way, C++ looks quite interesting - do you think it will be compatible with all current platforms, easy to put to asset store, no need additional steps for other developers to set up, Unity 5... and so on?

    I think I may start getting idea about formation. Are they used in all cases? i.e. how formations deal when your troops going through hills and mountains? And how does they rearrange if you send several troops into one location?
     
  4. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
  5. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    Sorry, about many sprite managers I meant having 1-3 sprite manages per nation/per soldier type not per unit.

    The sprite sheet actually is texture and the sprite manager just rearranges the uv coords of the sprite quad. So I guess it would be doable one texture per soldier type with all animations and angles.

    About kdtree lib. I will compile and test one, but not now beacause I work on something else.

    Formations can be treated as a single object. When needed extra calculations can be done locally on the units.
     
  6. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    In that case sprite manager should look very promising. Will need to start testing at some time.

    By the way, how do you create c++ libs? I may try at some point myself, as it's quite interesting area.
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    Also as I can recall the spritemanager class is always at 0,0,0 position. Perhaps it can be modified to be at other positions and applying the offset for the final sprite position so it works as expected. That would be useful to take advantage of the frustum culling. Because if every sprite manager is at 0,0,0 then it cancels the advantage of the frustum culling.

    About c++ libs it is a pro only future. See here: http://docs.unity3d.com/Manual/PluginsForDesktop.html

    edit: Consider also to multithread some of the routines.
     
  8. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Good, so correcting sprites, optimising search algorithms and bringing some formations could be good steps for further optimisation.

    Well, if c++ is a pro only, then we can stay with c# for a while. I guess there are so many different optimisation ways, that I am not even close to the need of c++ yet. But in the future it can be interesting point to check.

    If you have Unity Pro, did you also tried Unity 5 already? They say that they support multithreading already. Do you know if it works well at the moment?
     
  9. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
  10. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Interesting assets. Well, I will keep things up and we will see what will come next.
     
  11. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    I made some tests with the sprite manager:

    - There is no overhead when using multiple sprite managers. In fact it runs a little bit faster.

    - This could allow you to make each formation being managed by its own spawned sprite manager. You can move the manager and the sprites will be relative to its position. So navmesh calls should be made on the root manager only. (perhaps some randomization of the movement of the soldiers belonging to one manager should be added.)

    - So that leaves only the kdtree routine to become multithreaded which is easily doable in c#.

    I made some tests with unity5 pro. No significant performance difference.
     
  12. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    We forgetting one point about formations: if we want to use quads, we need to make their own textures, i.e. how they look from different angles. Texture making in runtime (procedural) can be very heavy, especially then quads move through non flat terrain and their shapes changes all the time.

    I can also pre-bake textures and just load them on runtime, like it is done with 3dSprites now. But if there would be additional levels of shape, they would be added on top of other levels, i.e. if I have 10 rotational levels in both vertical and horizontal components, I would have 100 textures in total. If I want to add 10 variations for shapes, it would end up with 1000 textures.

    Other things are when different units starts to play different animations on quads... Currently all these things are naturally solved with individual units, so I am not very sure if formations would fit here well, or they would be just a waste of time in trying to keep the current realistic approach.

    Kdtree is another thing - I think that current approach is a bit outdated. There are quite a lot of news about improved kdtree searches, which shows performance increase in orders. There are also some other searches, like approximate nearest neighbours. So I am keep looking what could solve these searches to bring at least 10000 units with fast searches.
     
  13. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    I just finished one important part with L-Systems. Near-realistic trees are now working with 3dSprites. As a result I checked how it looks like with uRTS and here it is:
    Screen Shot 2014-11-26 at 01.38.53.png Screen Shot 2014-11-26 at 01.41.17.png
    There is still plenty of space for optimising these trees, so probably soon we will see much better results. It also works nicely with all these thousands of knight and archers.

    Facebook demo is also updated with these trees, so everyone can check.

    L-Systems will go to Asset Store soon as separate asset, as some people who like these trees don't necessarily RTS. However, these trees plays important role in uRTS environment and demo models will be always included.

    We are on the edge of Unity 4.6 release, so prepare also to see some menus, buttons and interactive dialogs in game mode.
     
  14. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Just started to integrate some new UI menus and here how it looks like:
    Screen Shot 2014-11-27 at 23.20.50.png
    Check out also Facebook demo to find out how it works (currently it does not have functionality, but there is small 2 levels subsystem for Diplomacy button).
     
    red2blue likes this.
  15. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    Nice Chanfort ¡¡¡¡
     
  16. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    I notice in the demo that sometimes the characters' feet don't animate as they move (they look like they are sliding) and sometimes they walk backward. Can you take a look at these issues? Thank you
     
  17. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Thanks for message. Did you noticed when these issues are happening? Are they happening when scenes are very crowded and FPS drops down significantly? If so, if can be that sprite changes are delayed due to lower FPS, but in that case they should get updated a bit later. If no, that's would be really interesting. I expect that there can be some bugs remaining between different phases, but can you take a bit closer look at the behaviour when it happens?
     
  18. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    It's in your 12000 character demo on your website. Let it run a minute and watch the characters closely
     
  19. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,578
    Looks cool
     
  20. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    well, 12000 it's too much at the moment - this demo is just for testing purposes and currently is not very practical. Try the lower one (4000 I guess) or the best way Facebook demo. They are more practical examples, what you may want to see at playable FPS.
     
  21. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Some interesting battles naturally forming in mountains...
    Screen Shot 2014-11-30 at 16.44.13.png Screen Shot 2014-11-30 at 16.45.47.png Screen Shot 2014-11-30 at 16.47.25.png
    Make sure to check Facebook demo to fight against nations 3 and 4. To declare a war to these nations, go through "Diplomacy" button in the lower right corner.

    Economy is also working now - each nation has their own economies and if they are running out of their resources, they can't make more knights/archers. Upper bar shows player nation resources. Resources are slowly restoring in time.
     
  22. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    The Facebook one works a lot better but sometimes they still don't face the way they are walking. Sometimes they are facing up but moving right for example. Suddenly they will "blink" and then they are facing right and walking right again. It's a little bit jarring to see.

    Also when they swing their swords their feet don't move but they still slide around like they are ice skaters.

    Also when they die it seems like nothing happens to them except their healthbar disappears (but they keep fighting).

    Thank you
     
  23. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    That's sound ok and in upcoming future can be fixed. This blinking is because there are still quite large troops and there is not enough time to update them all so fast. So updater runs a bit slower. This should be solved automatically once I will apply upgrades to search phase and some other heavy parts of code.

    Well, they swing their swords and feet don't move because I am very bad animator and recorded these awful animations in blender. You should forgive me about this :) . In other words I will need to remake my models and animations...

    Yea, I only made idle, walk and attack animations, so death animation is not in my models yet :( This one is quite tricky...

    Are here some animators, who would like to help a bit with modelling and would accept to publish their models for free? In general I need several other character models and some building models as well to completely implement the town.
     
  24. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    If your model have a die animation ,It is very easy to implement ....;)

    [​IMG]
     
    chanfort likes this.
  25. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    you got nice work done. By the way, is that scene running on 6 FPS?
     
  26. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    :) I forgive you but I don't think I quite explained properly... the attack animation looks fine if they are standing still while swinging the sword.

    But if they are swinging the sword and start moving toward the enemy, their legs should go back into the walk animation while the upper body keeps doing the swing animation (right now the feet simply don't move at all even though the character is moving).

    Again, the attack animation looks fine if they are standing still.
     
  27. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    well, that's reasonable, as currently there is no phase implemented to keep attacking and walk in the same way. Currently they start to attack their targets when they approach them at some distance. If target moves to far away, attackers stop attacking and start walking in regular way until they are close to their targets again. Then they stop moving and start attacking. I can think about this intermediate phase when attackers are moving but also attacking on the same way.
     
  28. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    yes......I have 5 nations......2000 soldiers......and I have a old computer with 256mb graphic card at this moment:mad::mad::mad:
     
  29. eridani

    eridani

    Joined:
    Aug 30, 2012
    Posts:
    655
    That's a good way to put it. There is an intermediate phase where the attacker is moving yet still attacking. Right now the characters slide around in this phase, and I think it ruins immersion a bit.
     
  30. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    well, there is actually no intermediate phase at the moment at all. So what I suspect to be happening is that animation does not switch as fast as attackers switch from attack phase to walk phase and in space they start to move while still playing attack animation. Anyways, performance solutions should deal with this issues as soon as I will implement them. For now you can try to use smaller troops, i.e. up to 1000 to minimise these effects.
     
  31. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    oh, I see. You can try also a bit smaller troops to use, as it's very easy to set these numbers in spawnPoints, while I am looking how to optimise search coroutine.

    p.s. are these grey ghost models behind the dead ones :) ?
     
  32. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Finally, first my playable game in on Facebook now! It replaces previous uRTS demo, which was just for testing. Current approach allows you to test and play at the same time. Make sure also you use Firefox, as in other browsers there are issues with scrolling while in game.

    The goal is to destroy all other nation bases. At the beginning you get 200 knights and archers. To get more, select single building, then click on "P" button in the right side. Icon of knight will appear. Click on it. Now number of how many warriors you want to get will appear and you can scroll with mouse to increase/decrease the number. Click on knight icon third time to start spawning warriors from selected building. If you want to go back at any step, click on "P" to close build mode.

    To beat armies of other nations can be challenging, because they starts to respawn knights and archers automatically from their buildings once their numbers get low. So play also with diplomacy. If you will select war and do nothing, you will be quickly defeated as they respawn from their buildings. Economy also counts - if nation runs out of some resources, their won't be able to spawn troops till it will be enough resources.

    Try to play a bit with it and let me know what you think and what bugs you find out. There are coming much more improvements in upcoming future to the whole uRTS.

    Facebook demo is here.

    I will also open Facebook page soon, where you all can share your stories and impressions from this gameplay :)
     
  33. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    chanfort:

    I made more tests and I got better frame rate by reducing the resolution of the navmesh.

    Perhaps you should consider to abandon Sprite Manager and use the Legacy particle system.
    It might be a lot faster and you can manipulate anything there.
     
  34. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Hi elias, thanks a lot for this. Navmesh looks very interesting. Is that frame rate much larger for lower resolution? I was thinking at some point to begin implementing my own pathfinding (as current baking nature of NavMesh does not allow large amount of control things in a way how I want to), which could be dynamical (i.e. D* algorithms), but that's still very early thoughts.

    Particle system is very interesting too. By the way, why Legacy?
     
  35. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    937
    The framerate went from 25 to 30 fps with lower navmesh resolution.

    Aron Granberg has a good pathfinding solution also. And a free one too besides the paid one. http://arongranberg.com/astar/

    I made tests in the past with the legacy particle system and was easy controllable and manipulated. I do not know about shuriken.
     
  36. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Well, I checked Aron's A* last year, but with free mesh solution it does not hold more that several hundred individual paths. I also noticed that sometimes some soldiers go out from mesh, so I decided to use Unity NavMesh after that time, as it holds several thousands of individual paths at the time.

    I heard that particle systems can hold up to 100k movable objects, so it would be really cool. I will start looking at this once I finish with these graphical implementations.
     
  37. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    705
    i already think's about one particle system it's can be amazing for sure
     
  38. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    well, it can be that particle systems will give a lot of benefits, but we will see when I will start testing it. I am a bit curious now how fast can be changing particle coordinates and flipping between materials as both processes will be used. Did somebody done these tests to get rough numbers?
     
  39. technotdc

    technotdc

    Joined:
    Oct 21, 2011
    Posts:
    60
    Hi chanfort....

    How can change the rate of fire (archers)

    Thanks
     
  40. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Hey, I guess there is somewhere in BattleSystem.cs some numbers in Attack phase, can't remember this one now. Just check with different values and see if it changes...
     
  41. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Some wooden things are coming up into uRTS...
    Screen Shot 2014-12-15 at 00.01.35.png
     
  42. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Just included death animation and updated arrow models:
    Screen Shot 2014-12-19 at 23.54.17.png

    These changes will go live soon with v2.0 update.
     
  43. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    Before Christmas there are very exciting news - the first medieval wooden style town from my own models is now very easy to build in uRTS. Here is the screenshot:
    town.png
    Facebook demo is already updated with these features. P.S If you can't see buildings at the beginning, just move around to find castle. By selecting it you will find "P" button and menu to build other buildings. Once you unlock and build factory, you can try to build some fences. They are very exciting as you can just paint them on terrain and they will be build along the path you painted.

    There will be many functionalities related with other buildings too (affecting economy, diplomacy, defence), some of them are already live. YouTube tutorials about how to use all these new features are also coming up soon.
     
  44. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    705
    nice happy to see new so remember me i read the post and is based on atlas by animation it's that's ?:)
     
  45. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    hi kilik, umm, I am not sure if I follow your question correctly. These knights and archers are using sprites manager scripts to perform these animations actually...
     
  46. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    705
    ok i have try new demo and i'am sorry but try select and move unit with no result
     
  47. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    I see what you mean. You probably playing in Firefox. There is some kind of bug with unityplayer or browser, so right click mouse does not work well at all. I noticed that right click in firefox is the same as left click. If possible, you can try to look how to enter full screen mode to have all controls in a normal way.

    Another way you can try in Safari - right click mouse works slightly better there, but still not perfectly (scrolling is not working in Safari). There should be a way how to enter full screen mode, which would allow full control...
     
  48. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    I just updated Facebook demo - there is now "FS" button in the top-right corner of the screen, which allows to enter full screen mode. I checked both - Firefox and Safari - right click and scrolling works now fine in full screen mode. Let me know if you find any issues related with this.
     
  49. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    705
    ok i have try with chrome it's look working i have build caserne and craft unit archer shoot my building !
    i fear final size for mobile
     
  50. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    462
    well, I guess you don't need to fear anything about final size for mobiles, as you can chose yourself how big your game will be and what features to include. If you are not using some features, you can delete some textures, models, etc. from final build.