Fengist

[1.3.x] Fengist's Animator - Initial Release

Recommended Posts

Fengist's Animator

NOTICE: This is a plugin designed for modders. NO PARTS!

.dll Download from Curse
 

NOTE: This is the first release of this mod.  Expect me to have gotten something wrong.

Support this and my other mods on.
Patreon.png

____________________________________________________________________________________________

Source Code: https://github.com/Fengist/Fengist-s-Animator (note: I do not code pretty. I code functional. Feel free to fix things and let me know.)

The license included in the .dll download is a modified Creative Commons Attribution-NonCommercial 4.0 International Public License

____________________________________________________________________________________________

This mod includes version checking using MiniAVC.
If you opt-in, it will use the internet to check whether there is a new version available.
Data is only read from the internet and no personal information is sent.
 

____________________________________________________________________________________________

 

Ok, so what is this?

Like most modders I had a need to spin parts. And like most modders I turned to Snjo's Firespitter. However, I sorta outgrew it.  As a result, I created my own plugin to spin parts.  However, the approach I took was to use Unity's built-in animations to do the work.  The result is, you can do a LOT more than just spin the part.

So, what does it do?

Rather than just spin parts, it plays animations.  Unlike animateGeneric it can be linked to thrust or throttle position. The animations can be reversed based on thrust reversing and they can be looped or played forward and backward. It can be used to animate batteries and can also animate parts based on their heat.

Some .cfg Examples

In the examples below is a video that includes my 'fish tail' engine. In unity, I created an animation of the tail moving back and forth.  I also added in the pistons pushing and pulling on each side of the tail (it's a steampunk thing).  Here's what the partModule looks like:

                MODULE
                {
                name = FAnimEngine // Name of the partModule to call
                animationName = fishAnim // Name of the animation saved in Unity
                partType = Engine // One of several part types which I'll describe below
                syncThrust = True // This tells the partModule to adjust the animation speed based on the thrust output of the engine.  
                loopAnim = True // This tells the partModule to essentially rewind the animation and play it again when it finishes.
                animSpeed = 3 // The play speed of the animation.
                }

And here's the partModule for the propeller engine below.  You'll notice some differences.

                MODULE
                {
                    name = FAnimEngine
                    animationName = propAnim
                    partType = Engine
                    syncThrust = True
                    loopAnim = True
                    animSpeed = 20 // This is an actual aircraft propeller so it needs to go a bit faster than the fish tail
                    useRotorDiscSwap = True // Uses the same technique as Firespitter to switch from a propeller to an alpha (blurry) spinning disc.
                    rotorDiscName = rotorDisc // This is the name in Unity of the disk to swap to.
                    rotorDiscFadeInStart = 0.2 // This helps to fade the disk in and out
                    propellerName = propeller // And this is the actual propeller which the plugin switches to when the prop speed is low.
                }

And here's the partModule for the glowing battery

     MODULE
     {
        name = FAnimEngine
        animationName = lightsAnim
        partType = Battery
        loopAnim = False
        animSpeed = 1
     }

As you can see this one is pretty simple.  It works like a cockpit lights animation except, the position of the animation is based on the percentage of battery life left. 

My first use was to create some 'flaps' over an exhaust for my submarine.  I wanted a LF powered generator.  The partModule looks like this.

                MODULE
                {
                               name = FAnimEngine
                               partType = Engine
                               animationName = doorAnim
                               syncThrottle = true
                               smoothThrottle = true
                }

In this case, the animation plays and stops based on a percentage of the throttle position.  As the throttle is increased, a set of 'flaps' open wider and wider until full throttle.  As the throttle decreases, the flaps close.  The smoothThrottle keeps the flaps from slamming shut or instantly opening to full when the user presses x or y.

 

Usage optoins:

  • name = FAnimEngine // Always this.
     
  • animationName = // The name of the animation you created in Unity
     
  • partType = // one of the below types
  1. Engine - The most common one I use. All of the options below can be applied to an Engine type.
  2. Battery - This links the animation to the ships total battery power. The animation stops at a position that equivalent to the percentage of total battery power. 
  3. Stirling - Setting part type to Stirling will tell the partModule to play the animation based on the part's Thermal Radiation Flux.  The hotter the part gets, the faster the animation plays.
  4. Intake - This one you'll probably not use.  It's specifically for my submarine. This finds the first intake available and play the animation when the intake opens or closes.  I use this to automatically raise and lower a 'mast' intake on the sub when it surfaces or dives.
     
  • syncThrust = true/false // The animation is linked to the thrust output of the engine. Do not use with syncThrottle
     
  • syncThrottle = true/false // The animation is linked to the throttle position. Do not use with syncThrust
     
  • smoothThrottle = true/fase //used only with syncThrottle to smooth the animation transition when the player rapidly changes the throttle.  Setting to false, the animation instantly jumps to a new location.
     
  • loopAnim = true/false // whether the animation should loop back to the beginning when it's finished playing.
     
  • animSpeed = 1.0 // Adjust this to make the max animation speed faster or slower
     
  • detectReverseThrust = true/false // If set to true and the engine reverses thrust, the partModule will reverse the animation.
     
  • smoothRev = true/false // If set to false the animation will instantly reverse directions.  If set to true, it will smooth the transition.
     
  • useRotorDiscSwap = true/false // Mostly for propellers it allows a blurry alpha disc to be swapped for a spinning propeller
     
  • rotorDiscName = // name of the disc you created in Unity
     
  • rotorDiscFadeInStart = 1.0 // When the rotor and propeller swap places
     
  • propellerName = The name of the propeller in Unity

Some visual examples:

If you watch this video you'll see some interesting effects, namely the fish tail.  That is an animation that's directly linked to the thrust.  Yes, the fish tail is a KSP engine.  The Archimedes engines also use this plugin to handle their spinning.

Spoiler

 

Here's another video showing how crazy you can get.  Each of these "umbrella's" is an actual KSP engine producing thrust. And again, the animation speed is based on the engine's thrust.

Spoiler

 

And that's just the beginning.

Here's an image of a propeller engine I created.  If you look closely inside the cowl, there's actually a crank shaft that spins with the propeller.  The crank shaft has a bearing attached and 4 piston rods attached to it.  As the crankshaft spins the bearing stays on the crank lobe and the piston rods move in and out of the pistons as the propeller turns.

Spoiler

a6Hui8b.png

And there's more.

If you re-watch the video of the umbrella drive, you'll see some green glowy things on the side.  Those are batteries. They use this plugin and the glow increases and decreases depending on their charge.  In the case of these batteries the green glow is an animated emissive.
 

Enjoy.

Edited by Fengist

Share this post


Link to post
Share on other sites
8 hours ago, Nightside said:

Wow, you've really made some incredible stuff! 

Thanks. It's a result of being dropped on my head as a baby.

Share this post


Link to post
Share on other sites

I noticed that this is already getting a few downloads.  If any of you folks create a mod that uses it, let me know and I'll start a list in the OP linking to release threads.

Share this post


Link to post
Share on other sites
On 6/11/2017 at 11:22 PM, SchwinnTropius said:

Since I'm on a modelling kick, you can bet I will tinker with this. :)

Enjoy. Once you get the animation working in Unity play with the sync and loop settings. That will answer a lot of questions.

Share this post


Link to post
Share on other sites
20 minutes ago, Fengist said:

Enjoy. Once you get the animation working in Unity play with the sync and loop settings. That will answer a lot of questions.

I'll keep that in mind, thanks. :)

Share this post


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.