- Home /
Swaying trees on iPhone?
Hello, I am wondering if it is possible to get trees I add as GameObjects in Unity Iphone to sway similarly to the way they do when added with the terrain editor in regular Unity. I'm assuming I would have to create some animation, but I haven't the slightest clue on how to begin doing something like that.
Any help is appreciated, Thank you!
Answer by equalsequals · May 31, 2010 at 03:12 PM
In addition to what @Jaap Kreijkamp and @Paulius Liekis are saying -
Create a bone rig and skin your tree mesh to it. Use as few bones as possible, as the large trunk and thicker branches most likely will not bend unless it's hurricane-grade wind.
The most efficient way to animate things on the iPhone is via animation clips (as per performance tests by the creator of Zombieville USA).
Additionally, yo make it as efficient as possible you want to make sure that your tree's all have a shared material so that batching will come in and clean up some draw calls.
Unity iPhone does not support animation culling so you may want to take it into consideration that even trees outside of the camera's frustum will continue to update their animation even when not rendered.
Hope that helps.
==
Answer by Jaap Kreijkamp · Mar 11, 2010 at 03:32 AM
The easiest way to have them just animated, but other solution is to just give them bones and have them updated through code (if you've got many trees this could impact performance). The animation could be kept simple by having only a few bones for the stem, but depending on the kind of leaves you have it would work better to have a few bones for the leaves as well to have them sway independently from the stem. Keep the movement subtle, so it's less obvious it's an repeating animation. To improve the realism of the effect you could start animation based on position (so for example, add an transform.postion.x * windspeed
delay before starting the animation).
Answer by Paulius-Liekis · Mar 22, 2010 at 08:52 AM
It's done using one bend-matrix per tree and shaders in regular Unity. You can't use such complicated shaders on iPhone, but you could skin your tree to two bones and then control them either using animation or manually. But in reality I doubt that you can do that - 10-15 trees it will eat all you processing time on iPhone ;) I wouldn't do that unless the trees are main characters in the game ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220612103234im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Pitfalls for characer/animations on the iPhone 1 Answer
Ani.Mate error when port a PC game to iPhone 2 Answers
Can I make animations snap to a frame? 1 Answer
Fruit Ninja - Cut fruit effect 3 Answers
How to achieve best fps for Animating - Built-in Unity animation or coded through Javascript? 1 Answer