Hi there Unity gang, it’s my first question here so here it goes.
I’ve searched the forums as well as the answers section but so far to no avail, so apologies if it’s been answered somewhere already.
I’m wondering if it’s possible to import a mesh object layer (FBX) that contains multiple polygons (tree billboards) and have those all rotate individually to face the camera, as per the attached gif ? Would it be possible to script something that would do this ? If not how would I approach it.
Basically I have about 500 trees (that have images + corresponding alphas), all positioned correctly in the FBX on a layer. I don’t really want to model them all up in 3D reposition in Unity.
I guess I could create a billboard of one but then how do I instantiate them to the correct locations ? I could use a secondary mesh whose points correspond to locations but have no idea where to even start with something like that.
I would suggest making a single tree sprite and add a simple look at script to make it look at the target (See Transform.LookAt()). Once you get that running properly, make it into a Prefab. Then use a For loop to Instantiate a new prefab at each point where you want a tree.
I was thinking the same thing. If you output point position data from your 3D package you should be able to use that to instance all the trees at run-time using a single sprite prefab. Export the sprite from your 3D package with the UVs, etc and they should batch render (unless something else stops them from doing so). This would be very flexible and allow you to customize more solutions later, such as dynamic loading, if needed.
Our free package UnityConstraints has a billboard constraint that you can use. It has a horizontal-only option (un-check “vertical”) which you will want for trees: http://constraints.path-o-logical.com . Also available in the asset store. By default this will keep the objects on a parallel plane with the camera, but you can add any target object you want.
It is also performance-optomized. The only way I can think to make the constrains faster would be to perhaps combine them all in to a single “manager” loop, but that will really only save you the performance hit from starting co-routines, which is probably not going to give you much more.
Thanks a bunch guys. Looks like I was sort of on the right track but have a little bit more to read up on. Will give this a go and get back to you on how it works out. Rafes - that looks pretty much spot on as to what I need, cheers for that.
I imagine this would be quite handy for other Unity Arch Viz folk that have all their folliage placed in a 3D app want to translate that into Unity.
Cheers for your input Demostenes. it made me explore the terrain engine as well tree creation a bit more.
I’m just starting off in Unity have mucked about with the terrain engine a little bit. I’m fine with using placing the pre-made trees. They are definitely the way to go in terms of realism but in my workflow I usually have hundreds of specifically placed trees (via points in CAD). So it basically starts of in CAD then goes along into some 3D app where the billboards are made automatically placed at those specific points. End product is basically that gif above. One layer with hundreds of billboards at the correct locations. The trees are usually quite specific in terms of species so I need to apply specific textures per each layer group. Basically just your standard Arch-Vis approach. In Unity I’ve managed to create a tree + single leaf as the billboard so essentially I can change that to anything I like then it’s just down to the placement of all those. Which is where I was sort of stuck. Just to be clear, in this case I’m not after realism, all I want is to quickly populate out the scene with hundreds of specifically located billboard trees. Be they one or multiple species.
Using what apatrick suggested along with Rafes package, cheers a heap guys , I made a little script that instantiates a tree prefab (simple camera facing billboard) to each vertex of a base FBX mesh. It works perfect and does exactly what one expects. The only obstacle I have to overcome now is dynamic shadows for these as this method is problematic when the billboards rotate parallel to the light source.
I have tried the suggestions below, but it does not seem to work ?
As in the proxy shadow caster is either visible casting shadows or invisible not casting shadows when alpha is turned up to max.