Jump to content

Recommended Posts

i am an avid modder of parts but i haven't really done anything code based bt i am trying to tackle an upcoming issue, LoFi has dropped all modding and thus with the wheel collier and wheel module updates around the corner, i have inspected the mod and noticed the texture animator .dll, i cannot however find an odvious module that it references in his configs, plus LoFi has lost the source files and cannot help, so inshort i wish to keep tank tracks in the game but i would like a way to do it from scratch rather than se a plugin i cant edit what i would like is a texture animator plugin that can move a texture based on the RPM of the wheel colliders, or a reference wheel collider ( i should be able to set up a free wheeling collider at the mid point of the track to reference pretty easy, i can see how to do it, i just dont have the ability of knowledge to code it,  would anyone be able to give me a hand either with the coding or direct me towards the best place to learn how to code (html is my limit so far) specifically as it applies to ksp. my aim is to keep tank tracks in ksp, they may not be as feature packed as LoFi's but they would work but i have n idea how to make the treds move unless i can get a plugin coded

Link to post
Share on other sites

I've seen LoFi's tracks too and just ran across something that looked promising as a way he may have managed to animate the textures. I was able to get a basic proof of principal going - here's the code:

Spoiler

using System;
using System.Collections.Generic;
using UnityEngine;
using KSP.IO;

namespace Movetex
{
    public class ModuleTextureMover : PartModule
    {
        protected const string modTag = "[ModuleTextureMover] ";
        protected Vector2 texPosition;
        protected bool dirX = true;
        protected Vector2 speed;
        protected MeshRenderer MF = null;

        public override void OnStart(StartState state)
        {
            Debug.Log(modTag + "-> OnStart");

            base.OnStart(state);

            MF = part.GetComponentInChildren<MeshRenderer>();
            if (MF == null)
                Debug.Log(modTag + "MF == null");

            if (dirX)
            {
                speed.x = 0.01f;
                speed.y = 0.0f;
            }
            else
            {
                speed.x = 0.0f;
                speed.y = 0.01f;
            }

            Debug.Log(modTag + "   OnStart ->");
        }

        public void FixedUpdate()
        {
            if (MF != null)
            {
                texPosition += speed;
                if (texPosition.x > 1.0f)
                    texPosition.x -= 1.0f;
                if (texPosition.y > 1.0f)
                    texPosition.y -= 1.0f;

                MF.material.mainTextureOffset = texPosition;
            }
        }
    }
}

I've just dived into plugin coding myself so am not the best to expand this. If you can find someone willing to take this up that would be great. If not I could make a stab at it but progress would be very slow.

Not sure if this is required for something so trivial but if so license is CC 0.

Link to post
Share on other sites

What do you mean by " LoFi has lost the source files" ? All KSP plugins have an obligation to share their source, so if they are not on github or a similar site they should be in the mod zip. 

 

Edit : after a quick search the source are far from lost

Edited by sarbian
Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...