nubeees Posted July 27, 2022 Share Posted July 27, 2022 9 hours ago, Krafpy said: @nubeees I'm not sure if I understood correctly but I guess what you mean is that the lines appear first where you placed them (in the map view), but then seem to drift away from the planet. Am I right ? If that's the case, I think I encountered the same problem. I solved it by constantly updating (recalculating) the positions of the lines' points at each frame in Update or LateUpdate. And I don't think you even need to attach the line object to any other object if you do that, except the scaledScene. Yes, sorry if my phrasing was poor. I was hoping to avoid needing to repeatedly update the position of the lines, but sounds like that's the way to go. Thanks! Quote Link to comment Share on other sites More sharing options...
Box of Stardust Posted July 30, 2022 Share Posted July 30, 2022 (edited) EDIT: Can anyone give me a code snippit on how to find if a symmetry part of a part being placed is on the right side of a vessel? Edited July 31, 2022 by Box of Stardust Quote Link to comment Share on other sites More sharing options...
Jason Melancon Posted July 31, 2022 Share Posted July 31, 2022 I'm having a crash in my plugin where two different event handlers — one for OnFlightReady, and one for .Net's FileSystemWatcher.Changed — call the same method, inside which is a call to ScreenMessages.PostScreenMessage(). The first one that fires is OnFlightReady, and that works fine. But the moment the second call comes as a result of the other handler, the game crashes, and I can't understand why. It's got to be the PostScreenMessage call, because if I take that call out of the method in which it appears, and just log a string instead, that works fine, multiple times, no matter which event handler it's called by. Why would two calls to PostScreenMessage crash the game? Quote Link to comment Share on other sites More sharing options...
Jason Melancon Posted August 1, 2022 Share Posted August 1, 2022 Actually, now that I log a string in the OnFlightReady handler and comment out the method call, the game crashes on the first execution of PostScreenMessage() in that same method, rather than the second execution, when called by the FileSystemWatcher.Changed handler. And I stress that it's not merely PostScreenMessage() that doesn't work, because it works fine when the method it's in is called by the OnFlightReady handler. It's also not the FileSystemWatcher.Changed handler by itself, since it works fine when all it does is log the message rather than putting it on the screen. It's the combination of FileSystemWatcher.Changed and PostScreenMessage(). And the crash happens even when the message displayed is identical for both handlers, and when I print a dummy string to the screen. This makes no sense to me. I had been registering the two listeners in different places, with OnFlightReady in Start() and FileSystemWatcher.Changed in Awake(). I changed it so that both get registered in Start(), which is executed much later in the life cycle. I also put a call to PostScreenMessage() directly in each handler, so they no longer call it indirectly. This produces no change. Both handlers log that execution begins. The only difference is that an on-screen message displays just fine when done in OnFlightReady's handler, and the game crashes when the same is done in the other handler. Quote Link to comment Share on other sites More sharing options...
Jason Melancon Posted August 28, 2022 Share Posted August 28, 2022 (These last two have been answered in the main forum: https://forum.kerbalspaceprogram.com/index.php?/topic/209264-postscreenmessage-crashes-when-called-in-net-event-handler/) Quote Link to comment Share on other sites More sharing options...
mhoram Posted September 3, 2022 Share Posted September 3, 2022 I am trying to change position and rotation of parts while in-flight. My approach was to use Part part; Vector3 newPosition = XXX; Quaternion newRotation = YYY; part.transform.SetPositionAndRotation(newPosition, newRotation); This code has the effect, that the part gets set to the new position and new rotation for a single Unity-frame. Beginning with the second frame, the part is reset to its previous position and rotation. I conclude, that there is a functionality in place to reset the values, but I am unable to find information about this functionality. I also searched the forum and this thread for "part position transform", but could not find any information about this. I would appreciate it, if someone could point me in the right direction of how to change the position of parts. Quote Link to comment Share on other sites More sharing options...
justabeanie Posted December 10, 2022 Share Posted December 10, 2022 (edited) I just noticed this title's been missing an "i" in "unofficial" when I went over here to browse some threads. It's the little details that get you. Edited December 10, 2022 by justabeanie Quote Link to comment Share on other sites More sharing options...
apache-penguincopter Posted January 2, 2023 Share Posted January 2, 2023 I'm very new to this, does anyone know how i could get my craft stats (length, width etc...) in the SPH for my plugin? Quote Link to comment Share on other sites More sharing options...
Shantaboy Posted February 23, 2023 Share Posted February 23, 2023 I've been wanting for a while to develop a mod where everytime a kerbal falls on there head (ragdolls) one science point is earned. Any ideas on how to do this are asked and welcomed. If Ragdoll, Then Science +1 Quote Link to comment Share on other sites More sharing options...
apache-penguincopter Posted March 14, 2023 Share Posted March 14, 2023 On 2/22/2023 at 11:24 PM, Shantaboy said: I've been wanting for a while to develop a mod where everytime a kerbal falls on there head (ragdolls) one science point is earned. Any ideas on how to do this are asked and welcomed. If Ragdoll, Then Science +1 Maybe try FlightGlobals:KerbalRagdollNode? I'm super new to this and I don't totally know what I'm doing so sorry if this doesn't help Quote Link to comment Share on other sites More sharing options...
Shantaboy Posted March 14, 2023 Share Posted March 14, 2023 I'm in the same boat. Every little bit helps honestly. Quote Link to comment Share on other sites More sharing options...
TV4Fun Posted April 30, 2023 Share Posted April 30, 2023 I'd like to develop a mod that turns KSP into a Banished-like strategy game. As a first step, I'd like to implement an RTS style interface where you can control a single Kerbal's movements indirectly by clicking on the ground and having them walk there. Eventually I would like to have many Kerbals on screen at the same time all walking around independently. Any idea how I could get started on that? Quote Link to comment Share on other sites More sharing options...
WarpPrime Posted May 2, 2023 Share Posted May 2, 2023 I'm trying to figure out how I could get a list of all SpaceCenterBuilding objects within a certain radius. I know that I can get all parts within a certain radius with the code: (using KSPDev reference for KspLayerMask) var nearestColliders = new List<Collider>(Physics.OverlapSphere( pos, radius, (int)(KspLayerMask.Part | KspLayerMask.Kerbal))); I'm not exactly sure how I would be able to retrieve all buildings (i.e. VAB, SPH, etc) within the certain radius? Quote Link to comment Share on other sites More sharing options...
TV4Fun Posted May 3, 2023 Share Posted May 3, 2023 (edited) 3 hours ago, WarpPrime said: I'm trying to figure out how I could get a list of all SpaceCenterBuilding objects within a certain radius. I know that I can get all parts within a certain radius with the code: (using KSPDev reference for KspLayerMask) var nearestColliders = new List<Collider>(Physics.OverlapSphere( pos, radius, (int)(KspLayerMask.Part | KspLayerMask.Kerbal))); I'm not exactly sure how I would be able to retrieve all buildings (i.e. VAB, SPH, etc) within the certain radius? You should be able to do this by testing if collider.GetComponent<SpaceCenterBuilding> != null Edited May 3, 2023 by TV4Fun Quote Link to comment Share on other sites More sharing options...
WarpPrime Posted May 7, 2023 Share Posted May 7, 2023 On 5/2/2023 at 9:15 PM, TV4Fun said: You should be able to do this by testing if collider.GetComponent<SpaceCenterBuilding> != null The only problem here is that the current list only takes parts and kerbals. I don't know if KSPDevUtils.KspLayerMask supports selecting buildings. Can you please give me something a little more specific? Thanks! Quote Link to comment Share on other sites More sharing options...
TV4Fun Posted May 7, 2023 Share Posted May 7, 2023 1 hour ago, WarpPrime said: The only problem here is that the current list only takes parts and kerbals. I don't know if KSPDevUtils.KspLayerMask supports selecting buildings. Can you please give me something a little more specific? Thanks! All buildings and terrain are on layer 15, so you should be able to find them by setting layerMask = 1 << 15 Quote Link to comment Share on other sites More sharing options...
TV4Fun Posted June 3, 2023 Share Posted June 3, 2023 Is there a way to conditionally load portions of your code based on what other mods are available? Like for example, I would like to have my mod support KIS if it is installed, but not require it, so I'd like to have the KIS-dependent code only load if KIS is present. Quote Link to comment Share on other sites More sharing options...
kAerospace Posted July 28, 2023 Share Posted July 28, 2023 Anyone got an idea on how to cancel a vessel's angular velocity as soon as controls are let go (basically, so that, for example, pitching up increases the pitch angle directly instead of the angular velocity)? I've tried things like vessel.angularMomentum.Zero() and vessel.angularVelocity.Zero(), nothing seems to work though. Closest thing I got was with setting the vessel on and off rails, but that's pretty laggy. Quote Link to comment Share on other sites More sharing options...
fatcargo Posted September 10, 2023 Share Posted September 10, 2023 I didn't want to pollute the forum with yet another thread so i'm posting here instead. Does anyone know how to setup RelfectionProbe to reflect dynamic objects in flight scene, not just statics (like buildings and terrain) ? Ref: https://docs.unity3d.com/Manual/class-ReflectionProbe.html Please @xEvilReeperx if you have time ... Quote Link to comment Share on other sites More sharing options...
fatcargo Posted September 11, 2023 Share Posted September 11, 2023 It appears that ReflectionProbe.cullingMask is what i need to alter to get ships/parts and kerbals to be included in reflections/cubemap. so.,.. its solved. Quote Link to comment Share on other sites More sharing options...
TV4Fun Posted November 15, 2023 Share Posted November 15, 2023 Is there a replacement in `GameObject`-based UI for UI skin? I know with IMGUI, you could set `GUI.skin = HighLogic.Skin;` to have your UI have the standard KSP look. Is there an equivalent to that for the new UI system? Quote Link to comment Share on other sites More sharing options...
Fedex7501 Posted December 5, 2023 Share Posted December 5, 2023 Is it possible to open a part’s context menu from a module’s code? Quote Link to comment Share on other sites More sharing options...
zstewart Posted April 21 Share Posted April 21 Is there a way to dynamically change the name of a KSPEvent the way that (for example) the "Lights on"/"Lights off" toggle switches name in the part menu depending on which state the lights are in? Also, is there a way to dynamically show/hide different events depending on the state of the part/vessel, beyond just the guiActiveEditor vs guiActive? I'm building a computer module and need events for actions like "Boot" and "Shutdown". Obviously those can just be the same event, but I'd like the GUI label for it to change depending on the state of the part, rather than leaving it for the player to guess what the button will do. I'd like to know about adding/removing or dynamically showing/hiding events because I may potentially want to add additional events where there isn't always something for the button to do in every state. If not, I can always just change the label to 'not available' or something, assuming there's a way to change the label like that. Quote Link to comment Share on other sites More sharing options...
maja Posted April 29 Share Posted April 29 On 4/21/2024 at 11:53 PM, zstewart said: Is there a way to dynamically change the name of a KSPEvent the way that (for example) the "Lights on"/"Lights off" toggle switches name in the part menu depending on which state the lights are in? Also, is there a way to dynamically show/hide different events depending on the state of the part/vessel, beyond just the guiActiveEditor vs guiActive? /// <summary> /// Shutdown/Activate BV controller /// </summary> [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Shutdown Bon Voyage Controller", category = "Bon Voyage", requireFullControl = true)] public void ToggleBVController() { shutdown = !shutdown; Events["ToggleBVController"].guiName = (!shutdown ? Localizer.Format("#LOC_BV_ContextMenu_Shutdown") : Localizer.Format("#LOC_BV_ContextMenu_Activate")); if (!HighLogic.LoadedSceneIsEditor) { Fields["vesselType"].guiActive = !shutdown; Fields["rotationVector"].guiActive = !shutdown; Events["BVControlPanel"].guiActive = !shutdown; if (shutdown) { if (active) { BVController controller = BonVoyage.Instance.GetControllerOfVessel(vessel); if (controller != null) controller.Deactivate(); } } BonVoyage.Instance.SetShutdownState(vessel.id, shutdown); } else { Fields["vesselType"].guiActiveEditor = !shutdown; } } Quote Link to comment Share on other sites More sharing options...
zstewart Posted May 3 Share Posted May 3 Thanks. When I create files with the KSP sandboxed File API, do those files get cleaned up automatically when the vessel is destroyed? If not, how can I tell when the vessel (or editor part) is gone for good so I can delete the files to avoid filling disk space indefinitely? Alternatively, is there some other way to store particularly large chunks of vessel-related data? My mod requires storing a byte array which could be a few kilobytes or possibly low megabytes per part. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.