Jump to content

Light Animation works in VAB but not when launched


Recommended Posts

Hi all,

I have a few parts (multiple parts with the same problem...) where I have set up animations to control a spotlight. These animations work fine in Unity, -and- when the pieces are tested in the VAB when played through a ModuleLight. However, whenever the vessel is launched I lose control over those animations -- the 'lights on' toggle does not function any longer for that part, and the animation does not play at all; in fact the light is stuck at whatever the default animation state is (I can toggle it between default on/off during unity export). On these same animations, the emissive portion of the animation does not play either (which is why I think the animations are not playing properly outside the VAB).

~~However, I have other parts with -just- emissives in their animation that are using the ModuleLight without problem. ~~ Scratch that, the other anims are using Module Animate Generic

Stranger still -- If I change the ModuleLight to ModuleAnimateGeneric, the light works fine (both spot and emissive) (for the same animation!). Also, if I change the config setting of 'useAnimDim' (or w/e it is) to 'false', then the spotlight activates properly, but the emissive part of the animation is still not played.

The animations were created by cycling the 'enabled' property of a spotlight component for the chosen keyframes. I also tried by changing the RGBA values of the light. Neither way resulted in the animations playing properly outside of the VAB.

Sounds like I'm not setting up something properly in my Unity export or config for those animations... probably something simple I've missed in my reading or setup incorrectly...but it was a long night and I was a bit stumped. Any clues?

On a second note; is it possible to control the 'enabled' flag of multiple spotlights in Unity in the same animation (or some other way to control multiple spotlight sources on the same part through the same animation)? I could only get the first one added to the animation to cycle properly in Unity... and I don't think they worked properly at all once exported to KSP.

Edited by Shadowmage
Link to comment
Share on other sites

On a second note; is it possible to control the 'enabled' flag of multiple spotlights in Unity in the same animation (or some other way to control multiple spotlight sources on the same part through the same animation)? I could only get the first one added to the animation to cycle properly in Unity... and I don't think they worked properly at all once exported to KSP.

Yes I think the way to do that would be to make the animation apply to a mutual parent of all three lights (btw don't go overboard with lights. They're expensive) and animate each light under that parent.

Besides that what's the problem? It looks like you have it sorted.

Link to comment
Share on other sites

The real problem that I'm facing is that the light animations will not play properly outside of the VAB when called through a ModuleLight. They will be stuck with whatever the default animation state is for those objects (lit or unlit depending upon how it was setup when exported). However the animation plays without issue when played through a ModuleAnimateGeneric.

For now, I've just swapped over to using the ModuleAnimateGeneric for all of my lighting animations. They work exactly as animated when played through there. I would like to get the resource cost included in the lights and auto key to the 'Lights' action group, which is why I was attempting to use ModuleLight for those functions, but I suppose I can live without it. I will continue investigating, and post any fix that I can find.

Yes, lights are expensive to render; I originally had a pair of spotlights for front landing lights, but swapped one of them to a rear light, each on individual controls. So, for this part, it is only as expensive as the user tells it to be (by clicking the 'light on' button). :)

Link to comment
Share on other sites

Animation created in unity: Yes

Referenced animation name and light name in ModuleLight: Yes

The same animation controls both the emissive and light source.

At work at the moment... will post up the pertinent modules (and screenshots) shortly after I get home.

The animation plays properly when using ModuleAnimateGeneric, but not using ModuleLight. -- this is the part that has me completely baffled. As the part I'm working on is pretty complex (function wise), I'll likely try and create some simpler parts and see if I can get it working on part with a single module.

I am fairly new at working with Unity/animations though, so it may well be something simple that I am missing.

Thanks for time and help, I'm sure it'll get sorted out eventually.

Link to comment
Share on other sites

The light module, that works just fine in the VAB, but not when launched.

MODULE

{

name = ModuleLight

lightName = LMD-Light1Transform

animationName = SCA-LMD-LightsOn

useAnimationDim = true //setting this to false allowed the light source to be toggleable, but no emissive animation played; I have a feeling this tells the module to take manual control of the light source rather than use any animation

lightBrightenSpeed = 2.5

lightDimSpeed = 2.5

resourceAmount = 0.04

useResources = true

}

And here is the ModuleAnimateGeneric that plays the -same- animation just fine, with both the light source and emissive animating/lighting up properly, in or out of the VAB

MODULE

{

name = ModuleAnimateGeneric

animationName = SCA-LMD-LightsOn

isOneShot = false

startEventGUIName = Landing Light On

endEventGUIName = Landing Light Off

actionGUIName = Toggle Landing Light

}

Going to try out a few more random ideas, I'm pretty sure there is something silly that I'm missing or that is conflicting in my overly-complex part.

Link to comment
Share on other sites

Tried changing hyphens to underscores with no luck, will try with no special characters shortly, though I've not had any problems with those before. Edit: By 'no luck' I mean to say that there was no change; the animation still plays properly in the VAB, but not when launched.

SS of the animation keyframes / hierarchy

o3KPLe6.png

- - - Updated - - -

Further update -- on a random idea, I tried removing -all- other modules/etc from my part, leaving on the EC resource and ModuleLight; and now the animation plays fine when launched.

So... there must be some conflict between one of the modules in my part. Will do further testing to eliminate what the conflict is, though it is likely related to either ModuleEngines, ModuleGimball, or ModuleAnimateHeat (as I have a second part with the same problem, and those are the modules that they share).

For reference, these are the parts that I am working on... specifically the lander descent stage, and main service module: https://github.com/shadowmage45/KSPMods/wiki/Ship-Core:-Series-A (descent stage does not have the lamp in the renders on that page, was a late addition to the model and needs to be re-rendered).

Anyhow, thanks again for your help, you have at least motivated me to investigate further, and I think I am close to tracking it down now.

Edited by Shadowmage
Link to comment
Share on other sites

Yeah, ModuleLight's animated state conflicts with a number of other modules.

When I made the parachute-equipped docking ports for SDHI SMS, my docking ports had built-in lights as well. The lights can be toggled most of the time, but if the lights are on when the parachute is deployed, the lights remain on even when toggled.

Link to comment
Share on other sites

Good to know. I'll play around with it a bit more and see what I can sort out; it might still be name related, as I remembered some of the .cfg node definition/references have problems with underscores and hyphens (docking node, decoupler).

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...