Jump to content

Changing the EVA Kerbal model


Recommended Posts

Well, now I've managed to load animated objects, I can't figure the best way to switch the model at runtime:

-instantiate the model, make the Kerbal's model invisible, then change the position and the status of the imported model every update (probably the dirtiest but easiest solution)

-create a new part from the imported model, then add the "kerbalEVA" module to it (didnt' tried that yet).

-keep as much informations as possible from the original kerbalEVA, then mess with SkinnedMeshRenderers and animation...

And probably other tricks I didn't think of.

A challenge indeed, and I don't think I could come up with the best solution. But eventually I can make a quick tutorial on how to convert an animated mdl file to mu and load it, if it can help someone to make some tests. Could it help?

Good luck :-) Don't give up...

Link to comment
Share on other sites

I wasn't aware of those. DSSP's work is impressive, and his custom animator could be very useful.

I didn't had much time last week to make progress on this, but I'll get back to it ASAP. I've found how to create a Unity Ragdoll from models, and rigidbodies, but I didn't tried those in-game yet.

I'm tired of horribly deformed Kerbals, I need to be more methodic with my code. Having a GUI like DSSP's one to load models and assign animations could be a good start, I'll look into this.

Link to comment
Share on other sites

  • 1 month later...

Bumpity bump (and slight necro)

Depending on how lifelike you want your Kerbals to be and from how far away the illusion should be maintained, there might be another way.

You know bahamutod's Critter Crawler? It's only one part, but it can...well, crawl. If its model is changed and animations adjusted (with permission, of course), we could get walking "Kerbals" as parts!

...I don't actually know anything about working with Unity, so take this with a grain of salt.

Link to comment
Share on other sites

  • 10 months later...
Eventually, what I'm working on will become a mod, but it will take some time.

I can still share some snippets, since I need help from people who actually know how animated meshes works in Unity.

Here is a basic (and naive) example that modify the Kerbal from the main menu.

The source code from Toolbar (and his easter egg) has been very useful, and the main difference is this time I actually changed some meshes in the scene.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

//For this example, we will modify the Main Menu Kerbal, but this is possible in any other scene in the game.

namespace KSPMMModifyDemo
{
//This will be loaded at the main menu
[KSPAddon(KSPAddon.Startup.MainMenu,true)]
public class MessWithMMKerb : MonoBehaviour
{
//The kerbal from the Main Menu
GameObject MMKerb = null;

//Will be called at start
public void Awake()
{
MMKerb = getGOByName("kbEVA@idle");
MessWithKerb(MMKerb);
}

//return a GameObject from the scene by his name
private GameObject getGOByName(string sName)
{
//A naive (but working) way is to go trough all our loaded GameObjects, and find the one we want
foreach (GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject)))
{
if (go.name == sName)
{
return go;
}
}
return null;
}

//actually modify the skinnedMeshRenderers
private void MessWithKerb(GameObject kb)
{
//this will be a very simple example, let's just replace the Kerbal's helmet mesh by the one from the visor
SkinnedMeshRenderer smrHelmet = null;
SkinnedMeshRenderer smrVisor = null;

foreach (SkinnedMeshRenderer smr in kb.GetComponentsInChildren(typeof(SkinnedMeshRenderer)))
{
if (smr.name == "helmet")
{
smrHelmet = smr;
}
if (smr.name == "visor")
{
smrVisor = smr;
}
}
if ((smrHelmet != null) && (smrVisor != null))
{
smrHelmet.sharedMesh = smrVisor.sharedMesh;//Replace the mesh
smrHelmet.sharedMaterial = smrVisor.sharedMaterial;//Replace the material
smrVisor.enabled = false;//disable the visor
}
}
}
}


That will show something like this:

http://i.imgur.com/fgeF0NV.jpg

Still, I can't find some animated models to test this in-game. This is so frustrating: Anyone knows of a tutorial for a beginner in modelling that would allow me to create a basic animated stick figure?

Also, I found how to spawn objects from assets now.

i see you have dissabled the halmit, is there any way to load an alternative?

Link to comment
Share on other sites

  • 2 weeks later...

hi, I just picked up this thread.

You are aware of this mod yes?

Looks much the same to animate kerbals.

The bits where you mess around changing mesh's etc is interesting, similar to what Texture Replacer does to change the skinnedmeshrenderers on the kerbals.

My main interest at the moment is getting into the Kerbals meshes and animations in IVA mode.

I've found all the necessary information required as IVA kerbals are quite different to the EVA kerbals. Just haven't got the time to code a mod for it, but I supplied all the information on the Kerbal Animation Suite dev mod (first link) and hope that MrHappyFace will make the changes to support IVA kerbals.

Link to comment
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...