Jump to content

Solved: Lights are always on


Recommended Posts

I'm making my own spotlights and run across an issue: My light is always on.

This should be a simple fix for someone who has done this before because I can turn the light "on" and "off" in the menu and it draws electricity when "on" and does not draw it when "off". So I am 90% on track. The problem is that regardless of what state its in it is always shining and illuminating the world around it.

I suspect that my animation is not set properly and I admit that I did not set any of the animation properties under the assumption that the "on/off" action would do the hard work. I checked to make sure that "play automatically" is disabled, and it is disabled, so that probably is not related to the problem. I can only assume, then, that there is a property in the animation itself that should be set. I tried playing around with "enabled" and "intensity" under the light feature of the animation window but neither had an effect. I also tried the "enabled" entry under animation without success.

How do I get the light beam to animate on and off?

Can anyone shed some light on my problem?

*edit*

Had a brainwave and tried to animate the "range" of the spotlight to go from 0 to 20 over one second of time. It animates the way I want it to in Unity but did not fix anything inside of KSP. I wonder if I am on to something but missed a step?

SOLUTION:

There can only be one animation on the given part which controls the lights. If there are multiple animations doing multiple functions then the light breaks and wont animate.

Edited by Absolution
Link to comment
Share on other sites

Is your light on in unity? You want it off by default.

Can you expand on that? I tried turning it off three different ways and none of them worked so I must misunderstand.

First unchecked the box next to "headlight" at the top.

Second unchecked the box next to "Light" in the middle.

Lastly, for giggles, I tried unchecking the box next to "animation" at the bottom.

Each time I exported my model and reloaded it into KSP and there were no observed differences.

Inspector_zps60cdc6fc.jpg

Could my Hierarchy be part of the problem? My light object resides in an otherwise empty game object titled "headlight". The animation is attached to that same game object. Could that be it?

Hierarchy_zpse93ab354.jpg

Do I need to tag the object or set it to a certain layer?

Edited by Absolution
Link to comment
Share on other sites

More and more its looking like my animation is the problem. I tried Nazari's suggestion and set the intensity to 0 in its initial state and 2 to its final state. The result was that the light intensity did in fact start at 0 in game but it would not go to intensity 2 after turning the light "on" (it was drawing power but not shining). When I preview my animation in Unity it behaves the way I think it should and goes from intensity 0 to 2 over the course of the animation.

As an experiment I checked the "always animate" box in the animation inspector just to see what would happen. Despite having the initial intensity state still set to 0 as above the light was shining in game. Therefor the animation must be partially working because it did animate the light intensity from 0 to 2 automatically. That implies that the trigger that tells the light to animate manually is not working. When I set the light to "on" it doesn't fire the animation.

Okay, so as another experiment I changed the name of my animation to what squad uses for theirs "LightAnimation" because perhaps the KSP coding specifically looks for that name. No change in results.

My light is part of a bigger assembly and the config file incorporates multiple modules so maybe they are not playing nice together. To test that theory I removed all of the other modules that I thought would possibly interfere. No change in result.

My config file appears to be identical to that of squad's with the obvious exceptions to the entries to account for my unique naming. What the heck am I missing?

MODULE
{
name = ModuleLight
lightName = headlight
useAnimationDim = true
lightBrightenSpeed = 2.5
lightDimSpeed = 2.5
resourceAmount = 0.04
animationName = LightAnimation
useResources = true
}

I am starting to pull my hair out...

Link to comment
Share on other sites

is there moe than one aniamtion module? lights only work well when they are a single child so to say.

ding, ding, ding! We have a winner!

One of my many modules combined into this one single part is a solar panel which contains its own animation. I deleted the solar panel code from the config thinking it may be interfering but I never considered removing the asset out of Unity. Once I did the light started working perfectly.

I would really prefer to combine these two functions together so I tried combining the solar panel and light under the same animation. The solar panel doesn't actually animate but needs an animation it its hierarchy to work so I thought I could away with it. Turns out I can't.

I just need to bite the bullet and make two separate parts.

Thanks all for the help!

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