Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for saving PropRotating params in props for multiple rotating parts.
// Prop Rotating Script for multiple rotating parts.
// Control rotation axis, pivot and speed.
// Run in asset editor and see effects in real time.
// Prop Rotating Params Mod is not required for using the scripts and saving the asset.
// It's only needed to load the data in-game.
// The LODs are not rotating, they are like regular props.
// Vertex color blue channel for rotating parts must be 0.
// Non-rotating parts remain vertex color white.
// Google how to do vertex color painting in your 3d software of choice!
// You can have 4 different rotating parts, (0 to 3)
// each needs a different value for vertex color green channel.
// If you are making a clock, set clock value to 1.
// speed for the 12 hour arm is 2,
// for the minute arm it's 24,
// for the second arm it's 1440.
// Part 0 (vertex color green channel = 0)
var axis0 = new Vector3(0.0f, 1.0f, 0.0f); // Set to 1 to choose rotation axis.
var pivot0 = new Vector3(0.0f, 0.0f, 0.0f); // Pivot point - center of rotation.
var speed0 = 1.0f; // Rotations per minute / per day for clocks (negative to reverse direction)
var clock0 = 0.0f; // Set to 1 to tie rotation to game clock.
// Part 1 (vertex color green channel = 64)
var axis1 = new Vector3(0.0f, 1.0f, 0.0f); // Set to 1 to choose rotation axis.
var pivot1 = new Vector3(0.0f, 0.0f, 0.0f); // Pivot point - center of rotation.
var speed1 = 1.0f; // Rotations per minute / per day for clocks (negative to reverse direction)
var clock1 = 0.0f; // Set to 1 to tie rotation to game clock.
// Part 2 (vertex color green channel = 128)
var axis2 = new Vector3(0.0f, 1.0f, 0.0f); // Set to 1 to choose rotation axis.
var pivot2 = new Vector3(0.0f, 0.0f, 0.0f); // Pivot point - center of rotation.
var speed2 = 1.0f; // Rotations per minute / per day for clocks (negative to reverse direction)
var clock2 = 0.0f; // Set to 1 to tie rotation to game clock.
// Part 3 (vertex color green channel = 192)
var axis3 = new Vector3(0.0f, 1.0f, 0.0f); // Set to 1 to choose rotation axis.
var pivot3 = new Vector3(0.0f, 0.0f, 0.0f); // Pivot point - center of rotation.
var speed3 = 1.0f; // Rotations per minute / per day for clocks (negative to reverse direction)
var clock3 = 0.0f; // Set to 1 to tie rotation to game clock.
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_rollParams==null) Array.Resize(ref asset.m_rollParams, 4);
if(asset.m_rollLocation==null) Array.Resize(ref asset.m_rollLocation, 4);
asset.m_rollParams[0] = new Vector4(axis0.x, axis0.y, axis0.z, speed0);
asset.m_rollLocation[0] = new Vector4(pivot0.x, pivot0.y, pivot0.z, 1.0f-clock0);
asset.m_rollParams[1] = new Vector4(axis1.x, axis1.y, axis1.z, speed1);
asset.m_rollLocation[1] = new Vector4(pivot1.x, pivot1.y, pivot1.z, 1.0f-clock1);
asset.m_rollParams[2] = new Vector4(axis2.x, axis2.y, axis2.z, speed2);
asset.m_rollLocation[2] = new Vector4(pivot2.x, pivot2.y, pivot2.z, 1.0f-clock2);
asset.m_rollParams[3] = new Vector4(axis3.x, axis3.y, axis3.z, speed3);
asset.m_rollLocation[3] = new Vector4(pivot3.x, pivot3.y, pivot3.z, 1.0f-clock3);
var shader = Shader.Find("Custom/Props/Prop/Rotating");
if(asset.m_material != null) asset.m_material.shader = shader;
shader = Shader.Find("Custom/Props/Prop/Default");
if(asset.m_lodMaterial != null) asset.m_lodMaterial.shader = shader;
asset.m_lodHasDifferentShader=true;
asset.m_mesh.name="PropRotating2 "
+axis0.x.ToString("R")+" "+axis0.y.ToString("R")+" "+axis0.z.ToString("R")+" "+speed0.ToString("R")+" "
+pivot0.x.ToString("R")+" "+pivot0.y.ToString("R")+" "+pivot0.z.ToString("R")+" "+clock0.ToString("R")+" "
+axis1.x.ToString("R")+" "+axis1.y.ToString("R")+" "+axis1.z.ToString("R")+" "+speed1.ToString("R")+" "
+pivot1.x.ToString("R")+" "+pivot1.y.ToString("R")+" "+pivot1.z.ToString("R")+" "+clock1.ToString("R")+" "
+axis2.x.ToString("R")+" "+axis2.y.ToString("R")+" "+axis2.z.ToString("R")+" "+speed2.ToString("R")+" "
+pivot2.x.ToString("R")+" "+pivot2.y.ToString("R")+" "+pivot2.z.ToString("R")+" "+clock2.ToString("R")+" "
+axis3.x.ToString("R")+" "+axis3.y.ToString("R")+" "+axis3.z.ToString("R")+" "+speed3.ToString("R")+" "
+pivot3.x.ToString("R")+" "+pivot3.y.ToString("R")+" "+pivot3.z.ToString("R")+" "+clock3.ToString("R")+" ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment