- Home /
Can I make a billboard plane on terrain tree prefab?
I made a plane in Max and painted a tree with an alpha on it. I painted that tree (plane) on the terrain layer. I want it to have billboarding to always see my 3rd person game cam. Can this work with the terrain like that?
This is what i used as a script that i threw in the tree prefab:
function Update()
{ transform.rotation = Quaternion.LookRotation(Camera.main.transform.up,Vector3.up); }
The code I have isn't working though.
I also tried this with no luck:
function Update()
{ transform.rotation = Camera.main.transform.rotation; }
Answer by DaveA · Mar 23, 2011 at 10:18 PM
Did you try the Billboarding script from the script wiki?
Okay, just tried that script: http://www.unifycommunity.com/wiki/index.php?title=CameraFacingBillboard I tried to drag and drop the script into the tree prefab, but i got a popup telling me my object was not the same class type?
Did you drop it on the prefab (in the Project window) or an instance of the prefab (in the Hierarchy window)?
I tried dropping it in the Project prefab. I don't have an instance in the Hierarchy window...they're on the terrain layer.
Answer by Jason B · Mar 23, 2011 at 10:29 PM
Just out of curiosity, why not add your tree billboards as billboarded terrain grass? Would achieve the same effect. And for that matter, they would even be able to sway in the wind.
Answer by GreenHat · Mar 23, 2011 at 10:46 PM
hahaha no I did not try the Billboarding script from the script wiki! Now that I know that exists, I may juuust do that! Do you have a link?
The reason I didn't make it terrain grass is because my initial thought was: This tree type would only be painted far away from the player. I also have grasses as detailed grass. If I did the tree like this and it's only for distant trees, wouldn't I only see them as I just approached them like the grass layers? I know I can tweak the viewing distant of the grass details as a whole, but I don't want to have to 'draw' all that grass until i'm close...right?
Please add comments, rather than new answers, unless you really are answering your own question. $$anonymous$$akes it easier to follow.
Ah, alright. That reasoning does actually make sense. Your script should work, but I think you'd have to hand-place each far-off tree. As far as I know, painted terrain objects can't run scripts (someone correct me if I'm wrong).
Damn...so no real way to make my terrain plane trees billboard?