Jump to content

Lighted windows


Recommended Posts

I'm relatively new to the KSP part modding scene, although I have managed to create some station modules with (reasonably) working airlocks and EVA handles.

My next challenge is lighted windows toggleable in-game, similar to what Lack of LLL and udk_lethal_d0se have on their parts. How would I go about implementing this - are they animations with emissives, or something else?

Edited by sumghai
Link to comment
Share on other sites

Yes, they're done via animations. You change the Emissive.alpha and then use


MODULE
{
name = ModuleLight
lightName = lightname
useAnimationDim = true
lightBrightenSpeed = 1
lightDimSpeed = 1
resourceAmount = 0.01
animationName = animationname
useResources = true
}

to reference it in the .cfg

You may also want to add a light entity in Unity, that'll cost more processing power to run though. You do that by having the animation also change the intensity and range of the light.

Here's a quick picture I did for someone else:

bHAkbQ8.jpg

It's missing quite a few points, such as selecting the parent object (where you put the part-tools) when making the new animation, but you get the idea.

I was meant to write a proper tutorial about this, but kind of forgot. I should get round to that really.

Link to comment
Share on other sites

Mucho gracias, Lack - I managed to implement the lighted windows after a few hours of head-scratching.

Some extra tips/observations for those who may come across this thread:

1) [iGNORE - See Lack's workaround] Make sure your meshes are *direct* children of the PartTools GameObject in Unity's Hierachy

As a Blender user, I had the habit of directly dragging my .blend file under the aforementioned GameObject to import my meshes, resulting in the meshes being grandchildren (i.e. GameObject > *blender_filename* > desired_meshes). While this usually worked for most of my parts, I found that the nested hierarchy would prevent you from expanding the materials you wish to animate for the emissives.

The solution is to manually drag the meshes directly under the GameObject itself (i.e GameObject > desired_meshes), which allows the animation properties in the parent GameObject to actually be able to access the desired meshes.

Note that this does break any prefab connections between Unity and Blender, so if you make any changes to the mesh / UVs in Blender, you'll have to manually reimport your model(s).

2) Part windows lit in VAB/SPH part preview thumbnails list? Here's the solution

I've noticed that in Lack's canopy windows, when the part is previewed in the VAB/SPH part thumbnails list, all the windows are lit (although actually dragging the part out into the building area results in the expected dimmed windows). I suspect that the parts preview shows the model in its final end-of-animation stage.

If you're a stickler like me and want the part preview thumnails to also show dimmed windows, then define the initial alpha value of the emissive color to 0, and have the animation keyframes change it as usual - this will dim the lights in the thumbnail, but you'll still be able to toggle and animate the lights as normal during flight.

(PS If someone could verify my observations on their own setups, that would be great)

Edited by sumghai
Link to comment
Share on other sites

1) Make sure your meshes are *direct* children of the PartTools GameObject in Unity's Hierachy

As a Blender user, I had the habit of directly dragging my .blend file under the aforementioned GameObject to import my meshes, resulting in the meshes being grandchildren (i.e. GameObject > *blender_filename* > desired_meshes). While this usually worked for most of my parts, I found that the nested hierarchy would prevent you from expanding the materials you wish to animate for the emissives.

The solution is to manually drag the meshes directly under the GameObject itself (i.e GameObject > desired_meshes), which allows the animation properties in the parent GameObject to actually be able to access the desired meshes.

Note that this does break any prefab connections between Unity and Blender, so if you make any changes to the mesh / UVs in Blender, you'll have to manually reimport your model(s).

I encountered this problem on my first animation. Instead of breaking the prefab simply create/assign the animation on the Model, then to animate each mesh simply select them in the hierarchy.

PartToolsObject
-Model <- Create Animation here.
--Mesh <- Modify variables after clicking this,
--Mesh2 <- or this,
--Mesh3 <- .. or this.

That way you can expand each component on each mesh. The problem still remains where you cannot expand each component/mesh when you have the model selected.

Edited by Razchek
Link to comment
Share on other sites

Yeah, sumghai, you're observations are pretty spot on.

Re: 1).

You can tackle the not being able to select the drop down icon problem by holding down the left-mouse button, and dragging it from left to right across the row (towards the drop down icon), when it goes grey you can release and the menu will expand properly. Essentially the trigger for the drop-down isn't where the icon is visually, but it's still there. Or you can do what Razchek recommends, that works as well.

2).

I didn't discover that till later so have left it as is for the majority of the parts, my cupola parts have it set up so the icon isn't lit though.

Link to comment
Share on other sites

You can tackle the not being able to select the drop down icon problem by holding down the left-mouse button, and dragging it from left to right across the row (towards the drop down icon), when it goes grey you can release and the menu will expand properly. Essentially the trigger for the drop-down isn't where the icon is visually, but it's still there.

Thanks again, Lack - my part now retains the Blender/Unity prefab connection, while the animation can still be configured in Unity / played in-game.

In my particular case, I had a mesh in my model hierarchy dubbed "viewport_1" - in the original situation described in my last post, I would not have been able to open the materials instance in the animator. However, using a slight variation of Lack's workaround, I dragged viewport_1 from my main hierarchy to a position just below the corresponding item's materials instance in the animator - this has the effect of "forcing" drop-down icon open.

I suspect this is a minor bug with Unity, but at least there's a workaround for it now.

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

Thanks guys, this helped me a lot, though I replaced the .cfg code with the Space Plane plus one:

MODULE
{
name = ModuleAnimateGeneric
animationName = CockpitStandardLight
actionGUIName = Toggle Lights
startEventGUIName = Lights On
endEventGUIName = Lights Off
}

I did that because I wanted a simple light toggle without the RGB sliders, which I am not going to use for now. However, the right click menu has an entry reading Status: and it shows Locked when the light is on or off, and Moving when in between. This seems to be the result of ModuleAnimateGeneric.

Any idea how I can remove that Moving bit?

Edited by Camacha
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...