Skip to content

Instantly share code, notes, and snippets.

@ronyx69
Created May 17, 2018 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronyx69/318eab7a17c9d6a38d123eba0cefaab7 to your computer and use it in GitHub Desktop.
Save ronyx69/318eab7a17c9d6a38d123eba0cefaab7 to your computer and use it in GitHub Desktop.
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