Search Unity

[RELEASED] Prefab Spawner - Procedural prefab/GameObject spawner + Brush

Discussion in 'Assets and Asset Store' started by mkgame, Jan 3, 2018.

  1. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Asset store link: https://www.assetstore.unity3d.com/en/?stay#!/content/108365

    Procedural prefabs and GameObjects spawner. The world iterator can be used to generate random world positions or the brush can be used to generate such positions manually. Around the world position the Prefabs and GameObjects will be instantiated. Unique features are included, like proportional angle to height normal map or steepness dependent offset to avoid instantiating objects over the terrain.

    In game:

    Nature3.png

    - Multi terrain support
    - Steepness dependent offset
    - Proportional angle to height normal
    - Distance based scale
    - Height based scale
    - Random scalse
    - Random rotation
    - Distance weight based scale (kind of natural noise for forest)
    - Offset variation
    - Texture restrictions
    - Steepness restrictions
    - Height restrictions
    - Brush support for spawner
    - Multiple spawner selection
    and more...

    In asset:

    RiverVegetation.png







    SS4.png SS1.png SS3.png View attachment 260713
     
    Last edited: Feb 14, 2018
  2. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Sent to Unity approval.
     
  3. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Unfortunately approval takes too long. First update was already out after a few days, and now also the next version. So, the version will be 1.1.1.

    In update 1.0.1:

    - Some calculation issues were fixed.

    In update 1.1.1:

    - Global scale added.

    - Terrain texture amount based scale added for global and local object settings. E.g. can define: sacle down trees on terrain places where less grass texture is available.

    - Texture/slope/height constraints can be defined as positive or negative. E.g. Grass 50% to 100% grass texture must be available for an objects, or must not be available.
     
    Last edited: Jan 20, 2018
  4. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Some in game results. I made this asset to have an object spawner outside of Vegetation Studio, that has similar constraits. One aspect was the texture amount on the terrain patch.

    The assets used for the terrain:

    - Object Distributor (for spawning trees)
    - SpeedTree trees + Tropical Forest Pack from Baldinoboy (LOD based tree, needed nice and interactable trees, spawned by Object Distributor)
    - Vegegetation Studio (for grass, plants for some bush types)
    - MicroSplat (I belive this is simply by far the best terrain shader at the time)
    - UWS (even for river, it looks amazing)
    - turboscalpeur grass packages (using them in Vegegetation Studio)
    - Beautify (for my purposes the best screen space solution)
    - UniStorm (after my experience, for my purposes this is the most mature day/night and weather system)

    Nature2.jpg
    Nature7.jpg
    Nature3.jpg
    Nature6.jpg
     
    Last edited: Jan 22, 2018
    StevenPicard likes this.
  5. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
  6. Ostrov

    Ostrov

    Joined:
    Mar 9, 2013
    Posts:
    1
    Hi, mkgame!
    I've purchased your tool yesterday! It's nicely set in example scene and looks promising. But it's not very clear for me how to set it up from scratch - default values of distributor are empty and I have no result at all. It'd better to see it as generic distributor instead of voidness.
    And i have a question.
    How to set up a distributor to put my plants on the surface of the water over specific depth?
    Thank you!
     
    Last edited: Feb 2, 2018
  7. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi Ostrov!

    For your first issue, use one of the spawner prefabs. I know this issue, and for this reason I created some prefabs inclusive the default spawner prefab under the prefabs folder.

    You can just spawn objects on the terrain. However, you can spawn on the terrain under water by excluding the water layer. Add for your water a collider, set it to a trigger collider if you want. Then give your water collider GameObject e.g. the layer Water. Exclude the water layer for your water plants (Attribute at the bottom on the image). In the Scene_Isles the spawner ""Object Distributors->RocksLowerAndWater" instantiates rocks under the water.

    bandicam 2018-02-03 01-54-23-569.jpg

    Set the minimal and maximal height, where the plants on the terrain should be instantiated.

    bandicam 2018-02-03 02-00-39-457.jpg
     
  8. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    You can also add a texture under the water, where you want to instantiate. Then use the texture constraints and the height constraints to instantiate your plats. With the texture "mask" you can control where under the water the instantiation should be possible. In this way you can use the texture as mask.

    You can mix a low amount of the "mask" texture and you can then select this texture range e.g. sandTexture strength 0.01 to 0.02. With the height constraints you can apply it then just under the water.

    By the way, this asset works for terrain shader, which uses the default Unity workflow. Works for Microsplat (I use this) and should work with CTS and RTP too.
     
  9. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Example for river vegetation, just height and texture constraints needed:

    RiverVegetation.png

    I recommend to use Vegetation Studio for grass and water plants. It has similar constraints. If you want to instantiate bushes, trees (speedtree with LOD), plants (e.g. AFS shader based) as GameObjects, then for that you can use the Object Distributor.

    However, you can instantiate trees and bushes even rocks in Vegetation Studio and you can instantiate grass and bushes (LOD based, from e.g. SpeedTree) in Object Distributor. The workflow above was necessary for my RTS type game. Tanks driving over grass is bended by Vegetation Studio and driving over trees (GameObjects) interacts with tanks and will be broken or enrooted.
     
    Last edited: Feb 5, 2018
  10. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    In the next version it will be possible to spawn objects on collider with a certain layer, based on terrain restriction, like height. That means on low depth water (based on height restriction) water plants can be placed on the water surface.
     
  11. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    In the upcoming new release the objects can be instantiated on different collider layer, not just on the terrain. The main motivation for this update was to place water plants near to the riverside.

    bandicam 2018-02-16 15-30-58-806.jpg
     
  12. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    In the upcoming version it is also possible to place objects on a mesh, also around the mesh. Another nice feature is that you can create a brush with that you can place objects on terrain and on GameObjects at the same time. So, e.g. you can 'paint' grass on the terrain and on collider, which are in this case usually mesh collider, to have the instantiated objects exactly on the mesh and not in the air.

    'Painting' on mesh (mesh collider).

    bandicam 2018-02-16 22-27-02-881.jpg
     
  13. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    New features in the upcoming version and more detailed information about the powerful brush system.

     
  14. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    The new version 1.2.0 is uploaded and is in Unity approval state.
     
  15. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    The new version has been released.
     
  16. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    This has been done in version 1.2.0. There are now also default spawner available in the context menu.
     
  17. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Name will change to Prefab Spawner, that better explains for what this asset is.
     
  18. ALP8310

    ALP8310

    Joined:
    Feb 27, 2017
    Posts:
    142
    Multi terrain does not work, what to do about it?on the first terrain works on all subsequent no
     
  19. ALP8310

    ALP8310

    Joined:
    Feb 27, 2017
    Posts:
    142
    More details about this issue I sent you to the post help please
     
  20. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Sorry, I missed this. Where did you post it? The second scene is an example for the multi terrain feature. There is also a Documentation.txt attached to the main folder, that describes it:

    TERRAIN ASSIGNMENT

    - Terrains: Select multiple terrains, on which the Object Distributor will be applied. If no terrains assigned, then all the active terrains will be used.

    At the bottom is the "Terrain" array on which you can attach multiple terrains.

    bandicam 2018-06-13 23-12-56-339.jpg
     
    Last edited: Jun 18, 2018
  21. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    However, I recommend you to test your settings on a small terrain, eg. 512x512 and then apply it on 2000x2000 terrain or on multiple terrains.
     
  22. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I planning to add terrain texture preview for the terrain restrictions and a way to abort spawning objects (+ a progess bar). Maybe I will also make it possible to update at spawning the GameObjets, to have a instant preview that shows how the rest would look like.

    This asset may not looks beautiful, but I don't belive there is a more powerful tool to instantiate prefabs in the Unity editor. That means, I don't go in details, like spawn a desk and around chairs with random rotation and random possibility, but I provide a very detailed higher abtraction level, like spawn a forest with a higher possibility on higher ground, where the forest ground texture is at least 40%, restrict the max slope to 30 degree, smaller trees at forest border, and and keep the trees safely under the terrain by steepness dependent offset and terrain normal facing prefabs.

    This configuration can be placed by the brush, or can be applied on the terrain. For level designer placing by brush, by selecting variety of spawner (multiple selection of spawner) and setting the brush range to control density, is this tool not just a time saver, but it gives also a beautiful results.

    Eg. select a bush spawner and grass1 spawner, grass2 spawner, flower1 spawner, flower2 spawner, flower3 spawner and stamp an area. Then deselect the bush spawner and stamp an area. After, select a tree spawner, bush spawner, flower4, flower5, forestUnderground1 and 2, then stamp your forest. That simple is to create with the brush a controlled unique environment. You can also blend together areas by re-using some spawners, or just stamp both area types in each other with eg. half density.
     
  23. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Hi mkgame,

    when I spawn objects like stones a lot of them are floating in the air, not touching the terrain. Any suggestions how to fix this?
     
  24. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi, can you show me a screenshot? Are the collider fine on the stones, what version of Unity do you use? Maybe you could show the settings on the spawner. Maybe the offset settings are to high. Do you use additionally layers on that you want to spawn?

    Did you used a predefined spawner? (Right click on the context menu in the Scene View -> metadesc -> Add Default Spawner.
     
  25. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Colliders are fine (MeshCollider), offset is 0, no additionally layers.

    Some are floating and some are under terrain:
    Spawn1.png
    Spawn2.png
    Settings:
    Set1.png
    Set2.png
    Set3.png
     
  26. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi, thank you for the screenhots! The settings seems to be okay. You attached two prefabs to the spawner. Are the objects on the screenshots different objects? I assume the pivot point is not in the center of the object. If the pivot point is in the center, then can you send me your project?

    I also spawn a lot of rock types, that shouldn't be a problem:

    Rocks.jpg
     
  27. ALP8310

    ALP8310

    Joined:
    Feb 27, 2017
    Posts:
    142
    in the 2018 version, collision of collider objects works with errors, objects are superimposed on each other, you can check what the problem is!?=(
     
  28. ALP8310

    ALP8310

    Joined:
    Feb 27, 2017
    Posts:
    142
    I used to adjust collision radius of the collider now it does not work=((
     
  29. ALP8310

    ALP8310

    Joined:
    Feb 27, 2017
    Posts:
    142
    I repeat in the 2017 version of unity everything works correctly!help me please.....=(
     
  30. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    Is this able to spawn at runtime?
     
  31. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    859
    My guess is this asset is abandoned?