Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2018 18:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Allows limiting wind sway effect for trees with an adjustable multiplier.
// Tree Wind Sway Recalculator
// Recalculates vertex colors based on the height.
// Allows limiting sway with an adjustable multiplier.
var sway = 0.69f; // Sway multiplier 0.0 (none) to 1.0 (max)
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as TreeInfo;
Vector3[] vertices = asset.m_mesh.vertices; Color[] colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++)
colors[i] = new Color(0f, 0f, 0f, Mathf.Clamp(vertices[i].y/asset.m_mesh.bounds.max.y, 0.0f, 1.0f)*sway);
asset.m_mesh.colors = colors;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment