Last active
January 9, 2019 12:46
-
-
Save ronyx69/63f32ddd64c87e65c5c3ccee92f6077e to your computer and use it in GitHub Desktop.
Copy vertex paint from prop to vehicle sub mesh, use rotors shader on a vehicle sub mesh, adjust shader and tyre parameters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// reminder: the y axis ingame represents height | |
// (as opposed to z, usually used in 3d software) | |
// copy vertex paint from prop to vehicle sub mesh | |
// vertex color explanation | |
// RED for blimps(visibility): 0 visible when spinning, 255 visible when stopped | |
// IDK what red will do on other vehicles | |
// GREEN(tire parameter vector id multiplied by 8): color 0 uses 0, 8 uses 1, 16 uses 2 etc. | |
// BLUE(axis): 0 y axis, 255 x or z axis (if shader float _FlipTyreRotationXZ = 1) | |
// 0 = x (facing to the side, spins like a wheel) | |
// 255 = y (facing up or down, spins like a heli propeller) | |
// 255 = z (facing forward or backward, spins like a plane propeller, requires Rotors FlipXZ mod) | |
// | |
// for vehicles, vertex colors get generated and overwritten on import | |
// therefore you need to import the rotors sub mesh as a prop, save, reload | |
// and then import the vehicle sub mesh, | |
// and copy the vertex paint from the prop to the vehicle sub mesh using this script: | |
var subMesh = 1; // vehicle sub mesh id, starting from 1 | |
var asset2 = PrefabCollection<PropInfo>.FindLoaded("filename.Asset Name_Data"); // CHANGE TO PROP NAME | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
Color[] colors = new Color[asset2.m_mesh.vertices.Length]; | |
for (int i = 0; i < asset2.m_mesh.vertices.Length; i++) colors[i] = asset2.m_mesh.colors[i]; | |
asset.m_subMeshes[subMesh].m_subInfo.m_mesh.colors = colors; | |
// | |
// vehicle sub mesh rotors shader and tire parameters | |
var subMesh = 1; // vehicle sub mesh id, starting from 1 | |
var FlipXZ = false; // set to true to allow spinning around z axis | |
var tires = 2; // amount of "tires" | |
Vector4[] tireParams = new Vector4[tires]; | |
// tire parameter vectors: | |
tireParams[0] = new Vector4(8.0f, 3.0f, 0.0f, 0.0f); // pivot x, y, z, radius(doesn't affect anything) | |
tireParams[1] = new Vector4(-8.0f, 3.0f, 0.0f, 0.0f); // uncomment or add even more if necessary: | |
//tireParams[2] = new Vector4(2.0f, 4.0f, 1.0f, 0.0f); | |
//tireParams[3] = new Vector4(2.0f, 4.0f, 1.0f, 0.0f); | |
var fxz = 0.0f; if(FlipXZ) fxz = 1.0f; | |
var shader = Shader.Find("Custom/Vehicles/Vehicle/Rotors"); | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
if(asset.m_subMeshes[subMesh].m_subInfo.m_material != null) | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader; | |
if(asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial != null) | |
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader; | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.SetFloat("_FlipTyreRotationXZ", fxz); | |
asset.m_subMeshes[subMesh].m_subInfo.m_generatedInfo.m_tyres = tireParams; | |
if(FlipXZ) asset.m_subMeshes[subMesh].m_subInfo.m_UIPriority = 120122; | |
// | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment