Jump to content

Victor Ludorum

Members
  • Posts

    15
  • Joined

  • Last visited

Reputation

0 Neutral

Profile Information

  • About me
    Bottle Rocketeer
  1. I\'ve been looking at that recently because I\'ve been getting some really weird behaviour in plugins, with bugs appearing or disappearing depending on whether you construct a new ship in the VAB, restart with an unmodified ship in the VAB, or resume an already running ship etc. As far as I can tell, after onPartLoad() is called (during the initial game loading) the game saves the state of the part using serialization. It doesn\'t seem to use the standard C#/.NET serialization routines (maybe Unity\'s built-in serialization but I can\'t find much info on it). Then when a part instance is created it deserializes the stored part. Anyway, it looks like it serializes only public fields so you should be able to declare your List<> as public and anything done in onPartLoad() should carry through to each part instance.
  2. Make sure you\'ve applied scale and rotation (in object mode, selected everything and press Ctrl+A). I\'m not sure if you\'ll need to re-do the UV unwrap after that. Also make sure your face normals are all pointing out of the mesh.
  3. Yep, that appears to be the bit I was missing. Works great, thank you. I don\'t bother parsing the .cfg manual, just add the needed groups in onPartLoad() and it parses the fx_ lines properly.
  4. Well yes, I\'m guessing those particular groups are standard for all parts, that are fired automatically (?) when those events happen. But some parts (I think only the RCS thrusters at the moment) define custom group ID strings in the .cfg, like rcsGroup0 etc., that I think are triggered manually. If you derive a part from RCSModule, you can list the contents of fxGroups and find those custom IDs there (along with the standard ones). You can also trigger them to fire using [tt]findFXGroup('rcsGroup0').Burst()[/tt] and the like. However if you try to define your own custom fx ID in the .cfg you get an error during loading: ERROR: FX Group \'testGroup\' not found in TestPart So they\'re not being automatically parsed, you probably have to predefine them in the code somehow. All in all using Unity\'s particle system directly will probably be less work (actually I know it is; I already have it half-working, I just need to tune the effect parameters to what I want) but I\'d like to get a handle on FXGroups too, especially as they seem to handle sounds as well.
  5. Has anyone managed to get fxgroups working? I want to emit a visual burst kind of like when an RCS thruster fires. In the RCS block .cfg, there are lines like this: [tt]fx_gasJet_white = -0.609303, 1.58536, -0.0059382, -0.173648, 0.984808, 0.0, rcsGroup0[/tt] Which I assume is a position and vector, with some kind of ID string at the end. Then Part has a [tt]List<FXGroup> fxGroups;[/tt] which I\'m guessing is a reference to each fx_ line in the .cfg, though I don\'t know if it\'s auto-populated. (Edit: Turns out it is populated, but with FXGroups with ids 'prelaunch', 'activate', active', and 'deactivate'. None of the fx_ lines in the .cfg seem to be present so they probably have to be parsed/added somehow.) There\'s also [tt]Part.findFxGroup(string).[/tt] FXGroup itself has[tt] begin()[/tt] and [tt]Burst()[/tt] member functions. I\'ve tried a few things but without effect, mostly it seems I can\'t initialize the FXGroup correctly. Anyone had any more success than this? I guess I could learn Unity\'s particle system and create it from scratch, but it seems silly to do that when it\'s already in the game.
  6. As far as I\'ve been able to tell, all the Part.on{X} functions marked virtual (Part.onFlightStart(), Part.onPartExplode(), etc.) do nothing by themselves, so they are probably empty. It doesn\'t seem to matter if you call the base function or not, I\'ve yet to see any difference in behaviour.
  7. Consensus on the Unity forums seems to be that the integrator handles the scaling of forces (and torques) so you should not scale them by the timestep. (This makes sense from the way most numerical integration schemes work - the scaling is part of the integration equation, not the input constants.) It would be nice if we had access to the source code of some exemplar parts - an engine, a fuel tank, a winglet, etc. These would be invaluable for plug-in authors to ensure they are doing things the way the game expects.
  8. This is what I\'ve discovered/been using in lieu of any real documentation for the Part class. If you compile this and set is as the module for a part, you\'ll get a debug print (show using Alt-F2) as each member function runs. Note that the commented-out ones will spam the debug console if re-enabled. [tt] using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; public class DebugPart: Part { // Called when part disconnects from vessel due to crash etc. - seems to be called first // Also called when part is lowest part of a stack above a decoupler protected override void onDisconnect() { print('DBG: onDisconnect'); base.onDisconnect(); } // Called in VAB after onPartAttach() or any update of vessel in VAB // Also called after onPack() public override void onBackup() { print('DBG: onBackup'); base.onBackup(); } // Called in VAB when copying a part for symmetric placement protected override void onCopy() { print('DBG: onCopy'); base.onCopy(); } // Called continually when part is active anywhere in VAB, after onPartStart() protected override void onEditorUpdate() { //print('DBG: onEditorUpdate'); base.onEditorUpdate(); } // Called in VAB when removing a part after onPartDelete() // or in flight scene when destroying a part after onPartExplode() // also after part goes out of range (>2.5km) of focussed ship protected override void onPartDestroy() { print('DBG: onPartDestroy'); base.onPartDestroy(); } // Does not seem to be reliably called - mostly when decoupler explodes protected override void onDecouple(float breakForce) { print('DBG: onDecouple(' + breakForce + ')'); base.onDecouple(breakForce); } // Called at beginning of flight scene after onPartStart() // also when part comes in range of focussed ship (<2.5km) after onPartStart() protected override void onFlightStart() { print('DBG: onFlightStart'); base.onFlightStart(); } // Called for launchpad start after onFlightStart() protected override void onFlightStartAtLaunchPad() { print('DBG: onFlightStartAtLaunchPad'); base.onFlightStartAtLaunchPad(); } // Called when loading the flight state, such as when part goes off-rails public override void onFlightStateLoad(Dictionary<string, KSPParseable> parsedData) { print('DBG: onFlightStateLoad'); base.onFlightStateLoad(parsedData); } // Called when saving from VAB and during flight state save, such as when part goes on-rails public override void onFlightStateSave(Dictionary<string, KSPParseable> partDataCollection) { print('DBG: onFlightStateSave'); base.onFlightStateSave(partDataCollection); } // Called when any vessel control input occurs, even automatic // may be called during part placement before flight scene is properly setup protected override void onCtrlUpd(FlightCtrlState s) { //print('DBG: onCtrlUpd(' + s + ')'); base.onCtrlUpd(s); } // Called when game is paused (ESC) protected override void onGamePause() { print('DBG: onGamePause'); base.onGamePause(); } // Called when game in unpaused protected override void onGameResume() { print('DBG: onGameResume'); base.onGameResume(); } // Called when part soft-lands on water protected override void onPartSplashdown() { print('DBG: onPartSplashdown'); } // Called when part goes on rails (>500m from focussed ship) protected override void onPack() { print('DBG: onPack'); base.onPack(); } // Called when part goes off-rails protected override void onUnpack() { print('DBG: onUnpack'); base.onUnpack(); } // Does not seem to be called protected override void onPartTouchdown() { print('DBG: onPartTouchdown'); base.onPartTouchdown(); } // Called in VAB when deleting a part, just before onPartDestroy() protected override void onPartDelete() { print('DBG: onPartDelete'); base.onPartDelete(); } // Called in VAB when attaching to another part - 'parent' gives attached part protected override void onPartAttach(Part parent) { print('DBG: onPartAttach(' + parent + ')'); base.onPartAttach(parent); } // called in VAB when detaching part from vessel protected override void onPartDetach() { print('DBG: onPartDetach'); base.onPartDetach(); } // Initial call in VAB when picking up part // Also called when part comes into range of focussed ship (<2.5km) // And at initial part loading at program start protected override void onPartAwake() { print('DBG: onPartAwake'); base.onPartAwake(); } // Called when part is deactivated after onDisconnect() protected override void onPartDeactivate() { print('DBG: onPartDeactivate'); base.onPartDeactivate(); } // Called after explosion of part due to crash etc. // Seems to be after explosion effects are applied protected override void onPartExplode() { print('DBG: onPartExplode'); base.onPartExplode(); } // Called in VAB after onPartAwake() // Also in flight scene on vessel placement just before onFlightStart() // and when part comes into range of focussed ship (<2.5km) protected override void onPartStart() { print('DBG: onPartStart'); base.onPartStart(); } // Called during initial part load at start of game protected override void onPartLoad() { print('DBG: onPartLoad'); base.onPartLoad(); } // Does not seem to be called protected override void onPartLiftOff() { print('DBG: onPartLiftOff'); base.onPartLiftOff(); } // called regularly during flight scene if on focussed vessel - after each frame render? protected override void onPartUpdate() { //print('DBG: onPartUpdate'); base.onPartUpdate(); } // called continuously during flight scene if on focussed vessel protected override void onPartFixedUpdate() { //print('DBG: onPartFixedUpdate'); base.onPartFixedUpdate(); } // called regularly during flight scene if in active stage - after each frame render? protected override void onActiveUpdate() { //print('DBG: onActiveUpdate'); base.onActiveUpdate(); } // called continously during flight scene if in active stage protected override void onActiveFixedUpdate() { //print('DBG: onActiveFixedUpdate'); base.onActiveFixedUpdate(); } // called for parts connected to something else after onPack() protected override void onJointDisable() { print('DBG: onJointDisable'); base.onJointDisable(); } // called for parts connected to something else after onUnpack() protected override void onJointReset() { print('DBG: onJointReset'); base.onJointReset(); } // called when stage part is on becomes active protected override bool onPartActivate() { print('DBG: onPartActivate'); return base.onPartActivate(); } } [/tt]
  9. Man, I was just thinking of how well an Eagle would work as a model in KSP, with its modular structure. I hope you get the chassis/engines and pod parts modelled too. I have to confess I\'m kind of surprised anyone here is old enough to remember Space: 1999. I had the Dinky model of an Eagle when I was little, I used to love it.
×
×
  • Create New...