martincmartin
Members-
Posts
75 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by martincmartin
-
I have a MonoBehavior subclass. I take the difference in ActiveVessel's angularMomentum between successive calls to FixedUpdate(), to see how much torque was applied over the last timestep. This all works well, except when I revert flight, switch vessels, etc. How can I tell whether I'm in the first call to FixedUpdate() after such a change?
-
Why AliceWorld??
martincmartin replied to martincmartin's topic in KSP1 C# Plugin Development Help and Support
I just found one possible reason: if you have a direction (e.g. the direction towards prograde in your vessel's coordinates), the recommended way to get a rotation object from that is to use Quaternion.LookRotation(). But that assumes the "forward" direction is along z, and KSP assumes its along y. That is, they're separated by a rotation of 90 degrees about the X axis, which swaps Y & Z (as well as changing the sign of one, but that doesn't matter for LookRotation().) -
Why are Orbit's pos and vel in "AliceWorld" (y & z flipped)? Other than confusing developers, what purpose does it serve? Easier to translate into UI or something?
-
KSPUtil gone in 1.2.1?
martincmartin replied to martincmartin's topic in KSP1 C# Plugin Development Help and Support
I'm just quoting the "Modders Notes for KSP 1.2" that you linked to (thanks again for linking to that!). It contains the line: What does it mean by "not valid"? Is it just the value from the last physics update, or garbage numbers? I've been assuming its the value from the last physics update. Of course, the first frame after you switch to it, it could be a very old & essentially garbage number. But after that, hopefully it will be ok. -
KSPUtil gone in 1.2.1?
martincmartin replied to martincmartin's topic in KSP1 C# Plugin Development Help and Support
I am! And I want to use srf_velocity in my physics calculations, e.g. to know which direction is prograde (relative to surface, not orbit). But it seems srf_velocity is only valid in Update(), not FixedUpdate(). -
KSPUtil gone in 1.2.1?
martincmartin replied to martincmartin's topic in KSP1 C# Plugin Development Help and Support
Thanks! I also found this tidbit: Is there any way to get them between physics updates? That is, if FixedUpdate() is called 3 times between calls to Update(), is there any way to get srf_velocity and/or obt_velocity after each one? I guess I'll need to compute them myself... -
I did a little test: launch a rocket straight up, and a few seconds later (before drag can become significant), cut thrust (by pressing X). If I compute acceleration by subtracting consecutive Vessel.velocityD and dividing by time, I get what I would expect: between two frames, the acceleration instantly changes direction, and the new magnitude is 9.799. However, the "acceleration" field barely changes: See my log messages below: accel: (-3.475, 0.034, 2.243)(4.136), computed: (-3.487, 0.037, 2.255) (4.153), vel: (-29.271, 0.098, 19.660) accel: (-3.477, 0.034, 2.244)(4.138), computed: (-3.489, 0.037, 2.255) (4.154), vel: (-29.340, 0.099, 19.705) accel: (-2.900, 0.034, 1.854)(3.442), computed: (8.082, 0.016, -5.541) (9.799), vel: (-29.179, 0.099, 19.594) accel: (-2.323, 0.033, 1.465)(2.747), computed: (8.082, 0.016, -5.541) (9.799), vel: (-29.017, 0.100, 19.483) accel: (-1.746, 0.032, 1.075)(2.051), computed: (8.082, 0.016, -5.540) (9.798), vel: (-28.855, 0.100, 19.372) (The single number in parentheses is the magnitude). This is while Krakensbane.GetFrameVelocity() is still zero, so there's no floating origin problem. It's only about 4 seconds after lift off. Is the acceleration field some sort of time-averaged value? Once I shut off the engines, nothing on the vessel is actually accelerating at that rate. What is going on? I'll be happy to update the API docs with any answer.
-
Documentation for the KSP API
martincmartin replied to The_Duck's topic in KSP1 C# Plugin Development Help and Support
Can we unpin this thread? There are three pinned threads that claim they're the documentation for the API. From what I can tell, this is completely subsumed by the "New KSP API Documentation" thread? -
Thanks a lot Crzyrndm, that's very helpful. I put print("fixedDT: " + TimeWarp.fixedDeltaTime + ", deltaT: " + TimeWarp.deltaTime); in FixedUpdate(), turned warp up, and observed that deltaTime was always exactly equal to fixedDeltaTime from the previous print line. In FixedUpdate() I have: Vector3d deltaVelocity = FlightGlobals.ActiveVessel.velocityD - prevVelocity; print("accel: "+vessel.acceleration+", from fixedDT: "+(deltaVelocity / TimeWarp.fixedDeltaTime)+", from deltaT: "+(deltaVelocity / TimeWarp.deltaTime)); prevVelocity = FlightGlobals.ActiveVessel.velocityD; Then I launch a vessel and have it go straight up (roughly constant acceleration), and warp time, and I get: fixedDT: 0.02126373, deltaT: 0.02084686 accel: [-3.676, 0.070, 2.229], from fixedDT: [-3.615, 0.073, 2.193], from deltaT: [-3.687, 0.074, 2.237] ---------- fixedDT: 0.04007141, deltaT: 0.02126373 accel: [-3.682, 0.071, 2.231], from fixedDT: [-1.958, 0.040, 1.187], from deltaT: [-3.690, 0.075, 2.236] ------------- fixedDT: 0.0408728, deltaT: 0.04007141 accel: [-3.848, 0.075, 2.329], from fixedDT: [-3.621, 0.074, 2.193], from deltaT: [-3.693, 0.075, 2.237] So, if we compute using fixedDeltaTime, our computed accel is 1/2 size for a frame during the transition, but if we used deltaT, we're within a few percent, but not exact. I'll look into the two frame back thing when I get a sec, thanks for the tip. And thanks for the tip about the Krakensbane class, I had hear the name but didn't realize it was the name of a class! I should have guessed.
-
It turns out, TimeWarp.fixedDeltaTime is the time used in the next physics calculation. For my purposes, where I save the previous angularVelocity and subtract it from the current one, I want the value from the prev frame, which is TimeWarp.deltaTime. Thanks for the tip about floating origin, I didn't know about that so I read up about it. Where can I find the velocity of the floating origin? I tried computing vessel.acceleration from the various velocities in vessel (velocityD, rb_velocity, srf_velocity, obt_velocity) but couldn't get the correct answer. Perhaps correcting for the floating point origin velocity will help?
-
Thanks for the tip! I thought physics was run once per Update(), but looking more closely I see its run once per FixedUpdate(): https://docs.unity3d.com/Manual/ExecutionOrder.html I'm actually looking for angular acceleration, I'm just differentiating angularVelocityD, I'm working on a kind of improved SAS. I couldn't find that in Vessel, is it there and I'm not seeing it?
-
I'm computing some accelerations by recording velocities during every Update() call, recording elapsed time, and computing (currentV - previousV) / (previousT - currentT). I'm currently using mission time as my time, but (a) it doesn't advance while on the pad (not really a problem, but) (b) when the game is paused, it increases for the first two frames after the game is paused, but the physics isn't running, so all my accelerations are suddenly zero. What's a good value to use for physics time? Ideally: Doesn't advance when the game is paused Take into account warp, e.g. advances 3x as fast when warp is 3x (assuming Update() is still only called once, not 3 times?) Or is there a way to get "elapsed physics time since last call to Update()" directly?
-
I just updated to 1.2.1, and now there's no KSPUtil.dll anywhere in my KSP directory. Is this only gone on Mac, or is it also gone on Windows? Can I remove it from my project?
-
Thanks, that's a helpful starting point. Maybe your response should be made into a wiki page? Would be great if people could find it easily after this thread is buried. And it helps to remember that at low speed KSP is only simulating a small bubble, that explains a lot about the reference frames. The vessel really is at the center of the Universe.
-
Is there a guide anywhere to what reference frames are used to compute various positions, velocities and transforms? For example: FlightGlobals.ActiveVessel.orbit: pos and vel are relative to the center of the reference body, but seem to rotate along with it, although they're an inertial frame. FlightGlobals.ActiveVessel.GetTransform(): The position is (0, 0, 0) on the launch pad, then increases as you lift off, which makes me think the origin is on the launch pad ... until you clear the tower, when it goes to zero. And it seems to rotate along with Kerbin. Is there a description of the transform hierarchy somewhere? What's the parent of the active vessel?
-
I ended up just editing .csproj file by hand, adding these lines: <!-- Note that the OS for Mac is 'Unix', not sure how to specify a different dir on Linux if I ever needed to. --> <!-- Also, this assumes a Steam install in the default location, so its really a hack. --> <PropertyGroup Condition=" '$(OS)' == 'Unix' "> <KSPDir>/Users/$(USER)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program</KSPDir> <KSPExe>$(KSPDir)/KSP.app/Contents/MacOS/KSP</KSPExe> </PropertyGroup> <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' "> <KSPDir>C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program</KSPDir> <KSPExe>$(KSPDir)\KSP.exe</KSPExe> </PropertyGroup> <PropertyGroup> <KSPModDir>$(KSPDir)/GameData/AscentOptimizer/Plugins</KSPModDir> </PropertyGroup> <Target Name="AfterBuild"> <Copy SourceFiles="$(OutputPath)/AscentOptimizer.dll" DestinationFolder="$(KSPModDir)" /> <Exec Command=""$(KSPExe)"" /> </Target>
-
I'm trying to add Assembly-CSharp.dll and UnityEngine.dll in Xamarin Studios on Mac. When I go to Project -> Edit Resoruces -> .Net Assembly tab and click "Browse...", I can get to the steam KSP directory, but instead of "Ksp.app" or "Launcher.app", the browser has just KSP and Launcher icons, and when I click on them to try to navigate into them, nothing happens. How can I add the required .dlls on Xamarin Studios (aka MonoDevelop) on a Mac?
-
I've landed successfully on both Mun and Minmus. Yay! Now, I want to get as much science as possible from the different surface biomes. What's the most efficient way? I could create a lander with a big gas tank that could "hop" from the first biome to a second and maybe even a third, letting me get 2 or 3 biomes per round trip. I could attempt an Apollo style orbiter / lander separation, and dock with the orbiter between each surface expedition. I could make a rover and, with luck, drive to 1 or 2 nearby biomes. Or I could skip all that and just head to Duna. What's the best way to progress in career mode? In particular, I think I'd measure efficiency in science per hour of play time. But am also interested in science per kerbin dollar.
-
I have my first contract to put a satellite in orbit in this game, I've done it a bunch in other saves. The contract is for an equatorial orbit around Kerbin, inclination of zero. That means the ascending and descending nodes are undefined. On the contract notes when in space, it says "Longitude of Ascending Node: Undefined" (correct) and "Argument of Periapsis: Nan degrees." And the orbit isn't drawn on the HUD. Is this a known issue with 1.1.2.1260 ? My ap and pe are different (14km and 12km), and I don't know where to put them.