Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for saving PropRotating params in props.
// Prop Rotating Script
// 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.
// Animated faces must be vertex painted black! The rest reimains white.
// Google how to do vertex color painting in your 3d software of choice!
// The LODs are not rotating, they are like regular props.
var axis = new Vector3(1.0f, 0.0f, 0.0f); // Set to 1 to choose rotation axis.
var pivot = new Vector3(0.0f, 5.0f, 0.0f); // Pivot point - center of rotation.
var speed = 60.0f; // rotations per minute
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as PropInfo;
if(asset.m_rollParams==null) Array.Resize(ref asset.m_rollParams, 4);
var vec = new Vector4(axis.x, axis.y, axis.z, speed); asset.m_rollParams[0]=vec;
if(asset.m_rollLocation==null) Array.Resize(ref asset.m_rollLocation, 4);
var vec2 = new Vector4(pivot.x, pivot.y, pivot.z, 1.0f); asset.m_rollLocation[0]=vec2;
var veca = new Vector4(0, 0, 0, 1); asset.m_rollLocation[1]=veca; asset.m_rollLocation[2]=veca; asset.m_rollLocation[3]=veca;
var vecb = new Vector4(0, 1, 0, 10); asset.m_rollParams[1]=vecb; asset.m_rollParams[2]=vecb; asset.m_rollParams[3]=vecb;
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="PropRotating "+axis.x.ToString("R")+" "+axis.y.ToString("R")+" "+axis.z.ToString("R")+" "+speed.ToString("R")+" "+pivot.x.ToString("R")+" "+pivot.y.ToString("R")+" "+pivot.z.ToString("R")+" ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment