Jump to content

Fengist

Members
  • Posts

    1,777
  • Joined

  • Last visited

Everything posted by Fengist

  1. AutoDim won't be supported in the module I'm writing. I did a quick check and I think there might be 2 lights, other than stock, that use it. Here's why LightsOn and LightsOff won't work. In the stock module, those either play the animation attached to the light or they can use the autoDim to fade it in and out (stock lights use only the animation). If you're trying to simulate a blinking light that turns on for say 0.1 seconds, the stock light will still attempt to play that animation when you use LightsOn/LightsOff. But, by the time that 0.1 seconds has elapsed and you try to turn the light off, the animation has only played 0.1 seconds out of a full second (stock seem to be a 1 second animation). Therefore, the light doesn't fully come on before it gets shut off. My thoughts were, by toggling the useAnimationDim and useAutoDim to off that I would be able to either turn it on and off to achieve a blink or move the animation play head between the beginning and the end. With ModuleLight, that simply doesn't work. Even after setting both values to false, It will still attempt to use the animation.
  2. I guess I'm looking at it wrong. I assumed that the name of the animation component that I dropped into Unity would take on the name of the animation assigned to it. Yes, I used FindModelAnimator(s) to locate the animations it works fine, it just seems strange that the actual animation component would take on the object name. Thanks
  3. Ok, I'm not stupid. I have done this a bunch of times. But now, this is giving me results that... I frankly don't understand. foreach (Animation anim in part.GetComponentsInChildren<Animation>()) { Debug.Log("Found animation name: " + anim.name); } Ok, pretty simple right? Find me all the animations on the part and tell me what the name of the animation is. Or so you'd think. If the animation is somewhere in the hierarchy of the part, it's coming back with anim.name = the transform name (the one at the top of the inspector) and not the actual animation name. If the animation exists on the root GameObject, it's coming back with anim.name = the MODEL NAME from part tools. WHUT??? So somehow, thinking I've had a case of the stupids and all my other code that grabs animations is now junk, I decided to try this: foreach (Animation anim in part.FindModelComponents<Animation>()) { Debug.Log("Found animation name: " + anim.name); } And I'm getting the same result. Please explain as this makes verifying that I'm loading the correct animation by name rather difficult. Now here's where it gets really stupid. If I do this: List<Animation> list = new List<Animation>(base.part.FindModelComponents<Animation>()); int i = 0; int count = list.Count; while (i < count) { Animation animation = list[i]; if (animation[animationName] != null) { partAnimation = animation; } i++; } or some variation thereof, and tell it to assign the animation it finds to partAnimation by name (animationName), it's happy. It passes the correct animation over to partAnimation even though the name is wrong. I.E. animationName = lightsAnimation and animation.name = Model
  4. Yes, thanks, that's exactly what I did. It's not what I wanted but in 10 lines of code I achieved what was taking me hours and costing me money in pain killers. I was hoping for a set of 4 buttons with arrow icons to direct movement. After seeing exactly what it was going to take to achieve that... I mean I honestly tried. I got to the point I was adding the code into the KSP Asset as he calls it, and ended up throwing my hands up in disgust because it made no sense... all the references and callbacks. All this work for 4 buttons with arrows? It should not be this difficult. My end users will get stupid looking text buttons.
  5. I think I can do that. I'll send you a pm when I get something working. Now I understand. Ok, here's the good news and the bad news. The good news. A light like that would be easy to create. The bad news. I'm not going to do it. Sorry Here's why. You're asking for a part that will conform to a specific hull size, 2.5m in your example. Just off the top of my head, I can think of at least 6 different part sizes in KSP stock parts alone, maybe 7??? Now I have to ask myself, for the time and effort it would take to create 6 very specific lights, would they get used more or less often than a non-part specific light. Would I be better off spending my time moddeling 6 lights that fit any part, or 6 lights with each fitting a specific part? I think the former. I may change my mind in the future tho. Ah balls... you found my secret. In the world of KSP lighting, there's two ways a light can work. On/Off... basically the light on the model is switched on and off. In which case, the intensity can easily be modified. Next... animated. All of the stock lights and all of my lights use animations in order to create a bulb dimming effect. They fade in and they fade out. In my case, it's the actual intensity that's changing. I'm not sure if you've played with the lights I have in Maritime Pack but they work on the animation of the light intensity. And because of that, they can be a lot brighter than a light with a fixed intensity. Some people actually pull my lights out of the mod, ditch all the boat parts and keep the lights (Yea, I know a guy that does that). Now I have briefly considered this as a possibility. However, this isn't as easy as changing a value. This would involve digging into the actual animation curves, getting the values, creating new curves and... essentially... reworking the entire animation. And, to put this on a slider bar in the SPH/VAB, it would rework that animation every single time the bar was moved. Finally, I often have more than one light on a part. I may have a Unity Spotlight to cast the beam. But I may also have a Unity Point light to cast a 'glow' around the light. Each of those typically has very different intensities. So it wouldn't be as simple as creating one curve and applying it to every light. Long explanation but... no can do. Or rather, I ain't gonna do. Sorry.
  6. Nice tutorial. Definitely. And I got 90 percent of the way through setting up a GUI and decided my forehead couldn't take one more smash against my desk.
  7. @Li0n Let me know what you need for this to work with your mod. Basically, it's intended as a replacement for ModuleLight and many of ModuleLight's 'features' are already in there. Specifically, which calls to ModuleLight are you making and I'll make sure that's in the code. It already drops an action in the lights action group so that should work with your daylight on/off. Not sure if this still the same but being able to turn these off when they get automatically turned on would be a good idea. I watched Kottabos review and when I saw his lights turn off at night my first thought was, the battery went dead, not the mod shutting them off. That search light will eat up some battery power if left on. If you wish, prior to release I'll give you a test copy to play around with. The marker light already looks similar to the black one, just not angled. Changing the angle and direction of a light is not a problem. Where the issues come up is part of the way Squad coded things. Lights are only visible when they reflect off of a surface. So even if I do set an angle to a navigation light on an aircraft, if it's on a wing or some such, you won't know what angle it's shining toward as, in flight, there's no surface to reflect off of. Nextly, parts in KSP don't block light or cast shadows the way they should IRL. Therefore, lights end up shining through parts and out the other side. Yes, most annoying. The portable globe light, I can do something like that. I refuse to make it look like a clown balloon though. As for the bank of lights, show me an example of what you're thinking of. I get no mental vision from your description. it's possible to put probe cores, solar and batteries on parts, but that's kinda beyond the scope of this mod.
  8. Ideas... gimme ideas. Soon™ Still doing some internal testing. Still tweaking the ballasts (pun intended).
  9. No problem. This brings another idea to mind. I believe that Firespitter does something similar to what you want here. I believe @Snjo has helicopter blades that essentially duplicate themselves. The user selects the number of blades and he prodecurally takes a single blade from the model and places duplicates around a hub. I haven't looked at his parts in a few years but I think it was he who came up with that. I may be wrong. And yes, he definitely uses mesh swapping for some of his parts, which procedurally speaking, is relatively easy to accomplish. The problem you'll face there is the mesh is typically created beforehand and stored in the model's file. You may also want to take a look at some of Lack's parts in the LLL mod. He uses texture swapping to place 'pipes' and different faces onto some of his parts. Which these choices would give you the potential effect you're looking for, those textures and meshes were again, created beforehand and stored in the part's file.
  10. Well, nobody else has said this so I'll chime in. Unity is an incredibly powerful engine. I've seen it do some amazing things. I have no doubt that what you want to accomplish could be done given the time and the knowledge. However, as powerful as Unity is, you're looking at, for example, taking a cube and adding hundreds of polygons to its texture. And for nothing more tan aesthetic reasons. While there is much to be said about visual appeal you have to ask yourself, is the taxing this will put on the engine, and the end user's system, worth the load it will create? The first hurdle you'll have to overcome, if you persist in this pursuit, is how to completely... and procedurally... rework hard coded parts and models that are stored in files. And honestly, Unity allows access to a LOT of the model's settings in-game. Accessing the actual meshes and their polygons and trying to deform or add to them... I know of nothing in Unity that allows that. You'd be better off trying to create your greeble part and add it to the game rather than trying to deform someone else's parts (which might just torque me off if my steampunk parts gets turned into greeblepunk). Here's the tutorial that got me started years ago and it's still a very, very good one (Yes, I invoke the @Beale tutorial again). It will start you off using Wings 3D to model a part and then, show you how to get it into the game. GL
  11. Download from GitHub NOTE: Default light settings in KSP only allow for 8 lights due to the added resource loads lights can cause. To increase the number of lights available, go to Settings/Graphics/Pixel Light Count and adjust it according to your system's abilities. ____________________________________________________________________________________________ Compatible with @Li0n's Crew Light License is: a modified Creative Commons Attribution-NonCommercial 4.0 International Public License and view-able in the GitHub plugin directory. Source Idiot Lights! Read about them in this post Slime Lights Non-Idiot Lights And this is a stock aircraft on the runway with several of the lights attached to give a size comparison. So this all came about because I wanted some lights for a truck. After spending days trying to tie into ModuleLight I finally threw my hands up in disgust and wrote my own partmodule. Features: Works with multiple light sources on a single part using animations. GameObjects (lenses) so designated in the config can have their material color changed to match the light color. This happens real-time in the hangar. As you change the light color, the lens color changes. The color changer takes either _Color or _Emissive colors. GameObject (lenses) off colors - The plan is eventually to animate the lens colors to match the light color animation so that they fade in and out. I'm not there yet. Until such time, the lenses turn off and on during blink and remain on otherwise. The off color can be added in the .cfg file. Blinking lights - Most of these lights can be set to blink. On and Off times have a range of 0.1 sec to 10 sec. These are set via sliders in the hangar. Each light's blink time and blink state is set independently and is persistent Preset colors - Some of the lights on other mods I've seen have this cool blue shade rather than the stock yellow. With this plugin, you get 15 (at the moment) preset colors and the ability to add your own by adding to a dat file in the plugin directory. Preset format is: Color name,RGB.Red,RBG.Blue,RGB.Green I.E. Candle,255,147,41 Current color presets include: Candle 40W Tungsten 100W Tungsten Halogen Carbon Arc Warm Fluorescent Standard Fluorescent Cool White Fluorescent Full Spectrum Fluorescent Grow Light Fluorescent Black Light Fluorescent Mercury Vapor Sodium Vapor Metal Halide High Pressure Sodium Want more colors? Here's a website I found that has lots of them with their r,g,b values. Just add your favorites to the presets.dat in the Plugin folder. Future plans (hopes) Animating lens colors via code to match light colors (done) GUI menu to make that searchlight rotate and tilt. (done) Create a disco party truck (done) ProTip: To quickly locate these parts, search for Kerbal Electric in the hangar parts list.
  12. Well, technically, using just stock parts with default ModuleLight parameters, it's not a bug. If you change those parameters, then it will fail to work.
  13. [snip] I'm just gonna do what everyone else who's written a light mod did, write my own partmodule and not even attempt to tie into ModuleLight.
  14. So, after three days of screwing with this, I now have a clue as to why it's not working. I was attempting to hook into some of ModuleLight's abilities so that my code would work with stock lights as well. I'm now giving up as I have come to the conclusion that ModuleLight is junk. You would think, that setting the useAnimationDim and useAutoDim to false would give you a light that simply turns on and off. Wrong. If you use neither, you have no light. Which makes no sense. Another example of why it's junk. If I place a light using symmetry and then launch the vehicle and try to turn one of those lights on, it turns both on. Why are lights not using persistent fields to determine if a specific light is on or off? Why is it doing it by groups? Answer, because it's junk. You'll note the use of the word junk, so that my thoughts are not replaced by the vulgar words I'd like to use.
  15. Ok, this has me totally befuddled. Here's the basic code: ModuleLight allLights; allLights = GetComponent<ModuleLight>(); First I get the ModuleLight from the part. allLights.useAnimationDim = false; allLights.useAutoDim = false; allLights.LightsOn(); Lights on! allLights.LightsOff(); allLights.useAnimationDim = defaultDim; allLights.useAutoDim = defaultAutoDim; Lights off... or not. If I manually turn the light on, these two bits of code will turn the light off and back on. If I manually turn the light off, these bits of code will never turn it on. If I watch the PAW, it says that the lights are turning on and off. But the lights never physically turn on. What am I missing?
  16. Or something like this public static double GetResourceAmount(this Part part, string resourceName) { PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName); return part.Resources.Get(resource.id).amount; } public static double GetResourceTotal(Vessel v, string resourceName) { PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName); double amount = 0; foreach (Part mypart in v.parts) { if (mypart.Resources.Contains(resourceName)) { amount += GetResourceAmount(mypart, resourceName); } } return amount; } public static double GetResourceMax(Vessel v, string resourceName) { PartResourceDefinition resource = PartResourceLibrary.Instance.GetDefinition(resourceName); double amount = 0; foreach (Part mypart in v.parts) { if (mypart.Resources.Contains(resourceName)) { amount += mypart.Resources.Get(resource.id).maxAmount; } } return amount; } Now, this assumes you don't know the resource id and instead are using the resource name. It may be more efficient to get the resource ID first, store it and pass that to the functions so it doesn't have to get that every pass. I'm sure with some testing you can speed these up a bit. You'd call these functions as such: GetResourceTotal(FlightGlobals.ActiveVessel, "ElectricCharge");
  17. Thanks Repo, that's exactly what I'm seeing. I'm 'adding' to ModuleLight's PAW and I'm seeing the color bars from ModuleLight first, and then my PartModule fields and events after. I know I've seen other mods keep their fields/events/actions, like Kerbal Foundries wheels, arranged in a logical order. I just gotta figure out how he, and others, managed that. *edit* Oh hell. I just looked at his code and he's playing with drawGUI. I think I'll be happy being disorganized.
  18. I think I found the solution and if I did, it's stupid. I use Fireworks to edit my textures. The .png's it exports can have a solid background or a transparent one. If I used transparent the last image I saved, it defaults to transparent. Now, even if my textures are opaque but the background is transparent, Unity, or KSP's diffuse texture, thinks it's transparent and even sets the opaque areas to transparent. Yea, doesn't make sense to me.
  19. Are you trying to create an engine and use those partmodules or are you trying to apply thrust to a specific part?
  20. Any idea how to keep the KSPFields and Events in the order you place them in the code? The SPH editor seems to be sorting them with KSPFields first, UI_FloatRange's second and KSPEvents last.
  21. Seeking beta testers: In the coming days I'll have enough of the hovercraft plugin and parts working to start beta testing. This will be a plugin functionality test and not a critique of my modelling or texturing skills which have always been dubious. What you get: Very early access to the plugin and parts. Instructions (if you wish) on how the parts work specifically and how to create your own. Private access to my insanity. Requirements: You must have the latest Maritime Pack installed. These hovercraft will become part of that package. Discord! I've set up a discord server at this url: https://discord.gg/DYhKQmb Join it and when I get everything ready for beta testing I'll post a download URL. Only those on the Discord server will see it. What I expect: Feedback!
  22. Tests concluded, but you can watch repeats of the stream at that link. And sorry but for some reason I couldn't see the chat in youtube. The plans are to get the thing working properly and add it to MP. But that's just a plan. And yea, I've been experimenting with more reaction wheels but it doesn't seem to help a lot. The controllability went down when I added drag to the hover sections. Without the drag tho, I was hitting 200m/s with jet engines. And it seems that live stream video quality wasn't that great. That's what happens when you live in the boonies with sucky dsl. So, here's a better look at what was in the video
  23. If anyone happens to be around at this ungodly hour of the morning, I'm doing some testing of hovercraft code and I'm attempting to live stream it on youtube. Have a watch. https://www.youtube.com/watch?v=uwZozbk-Gos
  24. I swear to god upgrading Unity and to the new part tools is the WORST idea I've ever had. Now... it doesn't matter what texture I give a part it imports into KSP with the Unity main color with the texture over it. I have restarted unity. I've deleted all my .obj files and reexported them,. I've created all new textures. I select KSP diffuse and whatever that main color is below it is the color the part comes out as. It's like it's setting the shader to KSP unlit. Why? Perhaps a better explanation... I select KSP/Diffuse in Unity. I place my texture, which is NOT apha in any way, into the shader. Whatever the 'Main Color' is in Unity, that's the color my part gets set to in KSP The texture appears over it very lightly as if it's only 20% alpha. If I set the main color to red, the part in KSP comes out red with the WHITE texture alpha over it.
  25. Pretty much. But here's something interesting. @InfiniteDice (boat parts) and I were goofing off yesterday and he sunk some metal plates under the surface. Now here's the interesting part. He had a kerbal swimming down toward the plates and at 500m below the surface, when the kerbal touch the plate, he stood on them and started walking around. Now the question is, would anyone even want something where you could walk on surfaces under the water... or... sinking parts for that matter?
×
×
  • Create New...