Search the Community

Showing results for tags 'kos'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements
    • The Daily Kerbal
  • General KSP
    • KSP Discussion
    • Suggestions & Development Discussion
    • Challenges & Mission ideas
    • The Spacecraft Exchange
    • KSP Fan Works
  • Gameplay and Technical Support
    • Gameplay Questions and Tutorials
    • Technical Support (PC, unmodded installs)
    • Technical Support (PC, modded installs)
    • Technical Support (PlayStation 4, XBox One)
  • Add-ons
    • Add-on Discussions
    • Add-on Releases
    • Add-on Development
  • Community
    • Welcome Aboard
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
  • Making History Expansion
    • Making History Missions
    • Making History Discussion
    • Making History Support
  • International
    • International
  • KerbalEDU Forums
    • KerbalEDU
    • KerbalEDU Website


  • Developer Articles

Found 48 results

  1. Putting the Kexapod through it's paces. This is a demo of almost everything the robot can do to this point. Hope you enjoy. Craft and necessary files repository:
  2. [1.4.1] kOS v1.1.5.2 : kOS Scriptable Autopilot System

    Humm... Seems like my kOS computers aren't utilizing the RCS modules attached to my rocket.. Excuse me for my nasty coding. It's because I'm kinda new to C# / kerboscript, since I have only coded in javascript before. Code is as follows: print "Initiating launch procedure". sas off. rcs on. wait 2. lock throttle to 1.0. until ship:maxthrust > 0 { wait 0.5. wait 1. stage. wait 2. stage. } wait 5. from {local pitch is 90.} until pitch = 45 step {set pitch to pitch - 45/10000.} do { print "Pitching to... " + pitch + " degreeds.". lock steering to heading(90,pitch). if pitch <= 45 { print "Gravity turn achieved.". lock steering to heading(90,pitch). wait until alt:apoapsis > 90000. lock throttle to 0.0. wait until alt:radar > 70000. global pitch is 90. lock steering to heading(90,pitch). } } lock throttle to 1.0. wait until alt:periapsis > 90000. lock throttle to 0.0. print "Orbit successfully created!". While some of this code is not tested yet (Because I edited it slightly in preparations for this post), the problem should still occur. It is when i want to pitch my rocket to heading(90,90) that it only steers the vessel when thrusting, but not with rcs or inline reaction wheels and so on. Any suggestions (Btw, I haven't found anything that solves my problem, so I am asking here).
  3. Hey everybody, I could use some help with my kOS script, because I can not find my error. I play 1.2.2 with RO (no remote tech and remote tech.cfg removed from RO) and kOS My script describes a gravity turn. Steering up until a certain speed, pitching down by 10 degrees and waiting until pitch is aligned with srfprograde pitch. Then trouble begins: I unlock the steering to avoid the use of SAS with LOCK. I turn on SAS. I wait 0.01. And Im trying to SET SASMODE TO "SRFPROGRADE". But nothing changes. I´m unable to change the SASMODE. Also I use a function to automatically stage each time the SHIP:MAXTHRUST is less than 0.2. But upon flameout it won`t stage. Could someone please check, if my following script is the problem? The part, where I think the trouble is located is marked by red letters. Thanks very much! SET FlexPitch TO 0. // for Periapsis function LOCK THROTTLE TO 1. SAS OFF. RCS OFF. LOCK STEERING TO UP. STAGE. // Main Engine ignition WAIT 3. // Main Engine run up time STAGE. // Booster ignition + launch clamps WAIT UNTIL SHIP:VELOCITY:SURFACE:MAG > 40. // vertical speed for gravity turn LOCK STEERING TO HEADING (90,80). // Gravity turn pitching down 10 degrees WAIT UNTIL (90 - VANG(ship:up:vector, ship:srfprograde:vector)) < 80. // wait until sfrprograde pitch is less then 80 degrees. UNLOCK STEERING. // to prevent use of SAS with LOCK SAS ON. // SAS stability assist mode WAIT 0.01. // thought this would help with the next line SET SASMODE TO srfPROGRADE. // supposed to set sas to srfprograde but does not work UNTIL APOAPSIS { IF SHIP:MAXTHRUST < 0.2 // if the thrust decreases the stage is burnt out { STAGE. // decouples empty stage, activates retros, activates next engine SET SASMODE TO PROGRADE. // switching from surface to orbital prograde } ELSE { WAIT 1. }. // to avoid kOS doing too many calculations SAS off. // because I will use LOCK from now on until circularized LOCK STEERING TO HEADING(90, FlexPitch). // FlexPitch is 0 for now UNTIL SHIP:PERIAPSIS > 140000 { // Function pitches up or down, depending on vert speed IF SHIP:PERIAPSIS > 132000 SET FlexPitch to 0. // to keep vessel at around apoapsis altitude ELSE IF SHIP:VELOCITY:ORBIT:MAG < -50 SET FlexPitch TO 15. ELSE IF SHIP:VELOCITY:ORBIT:MAG > -50 SET FlexPitch TO (SHIP:VELOCITY:ORBIT:MAG / (-4)). }. } // no idea why this curly bracket has to be here, but it works only with it LOCK THROTTLE TO 0. // throttle idle UNLOCK STEERING. // unlocks the steering
  4. kOS Help?

    So i just installed kOS and I am trying to follow the tutorial found here. I get to Step 6 before I start to run into trouble. I type EDIT HELLO. like the tutorial says: Then I type PRINT "=========================================". PRINT " HELLO WORLD". PRINT "THIS IS THE FIRST SCRIPT I WROTE IN kOS.". PRINT "=========================================". again, like the tutorial says. I hit ENTER, then click SAVE and EXIT, following what the tutorial says, and receiving confirmation that it was saved But when I type RUN HELLO. it doesn't display the text like it should. It just says "Program ended." instead of displaying the text, then saying "Program ended." . Also, when I type LIST FILES. like how Step 7 of the tutorials says. But the console tells me that the script "hello" has a size of 0. Can somebody help me understand what I'm doing wrong? I thought I was following the tutorial correctly, but whatever I try will not work.
  5. Or more precisely how do you correct a gravity turn mid flight? So I have started playing with KOS and I am trying to figure out how to do a gravity turn. I am attempting to write a generic script that can work with a range of vehicles. I have written, what I feel, are a couple of really good predictive scripts that use TWR, Dynamic pressure, AP, Time to AP, vertical speed and Burn time. But they keep getting messed up by the changing TWR and staging. When TWR goes up the craft pitches down too early. Then at staging when TWR drops it realizes it has to pitch up a lot. I attempted using a TWR correction factor with little success as it appears the relationship is very non-linear. So I think I need a way to minimize pitching adjustments as TWR departs from average. Perhaps 1/((AverageTWR-TWR)^2+1/TWR). Would average acceleration would be DV/BurnTime? Thus making average TWR = Average Acceleration/9.8. I am just about out of ideas and the last thing I want to do is build a lookup table and fly to that.
  6. At the Kerbal Astronomical Conference 2K17, a certain young and rich Kerbal by the name Keylon took the stage. What he presented would upend the Kerbal universe. Taking a direct dig at KASA and the KLA, he accused them of not innovating in decades, and sticking to throwing away boosters, or trusting some unkerbal forces to recover their parachuted boosters. To add to this, he presented a preliminary work, done by his upstart company KAS:3X Industries, which focuses on eliminating the unknowns in the industry, and establish reusability on a scale no one has ever seen. This booster was built out of mostly current and stock KSC hardware, except a computer the size of a toaster. This debunked the KASA theory that computers get fried in space, and the achievement gave Keylon a cult following. Further, Keylon vowed to eliminate the automatic recovery option, and recover boosters manually. He claimed this would drop costs further, and demonstrate a new space age, where every Kerbal could access space at a reasonable cost. Now, all eyes are on the next major space conference, as Keylon has posted a teaser of a much larger orbital rocket on kReddit.
  7. Kos script Project

    Hi to all. In this Topic, I like to go Create scripts, together whit you all. From simple to complex scripts. "1 launche a rocket, to drive a rover, And yes, if we script it it is possible that we do it whit 2 or 10 objects at the same time" Its not that I now a lot about the scripting, but when we do it al to gether we now a lot more. So script along whit me, and how join the topic, to have fun whit the Kos system. Here is my GitHub for the file's. off scripts and crafts I use. If you also have a GitHub to share the file's let it now. WE set it all here so we can have fun, to share it..
  8. kos altitude trigger question

    I am new to this mod, and i am trying to make it so that my craft stages once at a certain altitude. When i type if alt:radar = 15000 { stage. } It does nothing when it crosses that altitude. Also, it doesn't recognize. if 14500 < alt:radar < 15000 { stage. } If I tell it to stage when it is below a certain altitude, it goes through all of the stages. How can I make it stage once at a certain altitude?
  9. Hello guys, I need some help over there. I need to know, how can I get the vector that always poits to the certain spot on the orbit. I'll try to explain. For example, I'm on my stable orbit. And I decide "Oh, such a nice place, I need a vector that starts on my craft and poiting there". Are there any built-in functions in KOS to help me? Or may be I can do it using maths somehow? I've spent a whole day trying to solve it, but nope, I don't know how to do it. Illustrative picture is here (I'm a newbie, so I dont know how to attach my pic without URL). Thx a lot
  10. This is my latest and most commiting project, making a SpaceX guidance system in Kerbo Operating System (KOS) The plan consists of 4 phases: Phase 1: Create a launch guidance script Phase 2: Falcon Heavy. Phase 3: boost back script. Phase 4: Landing. So why am i doing this. to help teach mathematics and physics within the Kerbal universe CREDITS: @Kartoffelkuchen for the SpaceX mod the current KOS developers and there will be more to come Phase 1: This is my most complex script to date i hope you enjoy and if you have any suggestions ill look into it! licence under All rights reserved (as its a script for education) HOWEVER because its for education If you ask you can redistrubute UPDATE: so ive dived into the source code for Mech jeb for ideas on the landing burn...seems complex *puts at bottom of pile which may or may not include a big mod*
  11. KerbX

    KerbX aims to provide a launch service to kerbin that the average joe can enjoy! you can watch our livestreems either on You Tube, our live coverage on Twitch. I hope you enjoy this. UPDATE 1: LAUNCH MANIFEST:
  12. So, the challenge is to create a kOS program that will launch a spacecraft, put it into a stable orbit around Kerbin, and land the first stage of the rocket on Kerbin, without any manual control (Except starting the program, of course) There is a point system Here is the amount of points you get or lose from doing certain things: MINIMUM: Get to stable orbit, deploy a payload, and land automatically, 1 point. Optional: Payload around Mun: 5 points Costs less than 10000: 5 points Payload weight larger than 50 tons: 2 points Lands near KSC: 3 points Lands on the launch pad: 10 points Lands without parachutes: 5 points Able to configure program to launch different vehicles just by tweaking a few values at the start of the program: 20 points Payload around Duna: 10 points Entire mission to Jool, with an orbiter relay satellite that deploys a probe with a heat shield and returns tons of data automatically: 50 points Good luck!
  13. I'm making a landing script on kOS, but now I had to kill the horizontal velocity of the ship. But for this I had to have the heading retrograde. In other words, lock orientation on retrograde but inclined to horizon to just kill the horizontal velocity. Have you some ideas to get this orientation on kOS ? (I'm not english, sorry for my potentially horrible syntax.) Thanks
  14. Ad Inexplorata

    I wrote a script to do a skycrane-style rover landing on Duna, and then decided to make a cinematic instead of my usual script-showcase-style videos. This is the first cinematic I've ever made, and I also intend to make one for my Mun landing soon! Music: The Force Awakens, Trailer #1, John Samuel Hanson The Mole, Dunkirk OST, Hans Zimmer No Place On Earth, The Heart of Man, Tony Anderson All scenes were filmed in KSP 1.3. Mods used: kOS Camera Tools Distant Object EVE FASA Hull Camera VDS Kopernicus KSPRC Planet Shine Reentry Particle Effect Scatterer Texture Replacer Replaced Real Plume ...and many, many config edits in Scatterer, EVE, KSPRC, and Real Plume Hats off to the modders that make this game bearable to look at (and film)! Thanks for watching!
  15. Hello everyone! I want to share with you my project called 'New Kepard'. It was inspired by New Shepard rocket landing: My goal was to recreate it in KSP using the kRPC mod which allows you to write your own scripts to control the vessel. The developement of the project took me much longer than I had originally thought (more than 100 hours). Writing the program which controls the rocket was not the hardest thing. Bugfixing, tweaking, testing and ensuring that the code is prepared for every possible flight scenario was what I spent the most of the time (~75%) on. I am now very happy that I made it to the end and didn't give up. I created two films about my project: The first one was edited to be similar to the original Blue Origin's video The goal of the second film is to show what my project is and how to use it Code and the craft are avaliebe to download on GitHub. I hope you like what I've done
  16. Since this challenge seems to be dead, I decided to post a new kOS challenge thread here. The challenges are aimed to reproduce the achievements of real-life space programs. Rules: Launch an automated mission controlled by kOS. Manual control is allowed on uncrewed missions in the form of typing commands into kOS console. On crewed missions, manual RCS controls and action group triggers are also allowed. All spacecraft must have an antenna on board which is capable of reaching Mission Control (if it is in sight) or relay network. Required mods: kOS RemoteTech Recommended mods: Community Tech Tree SETI-UbM or other probe-first tech trees Kerbal Engineer Redux RealChute FAR Some kind of life support Other noteworthy mods: KSC Switcher to launch from non-equatorial sites for extra bonuses Since the challenge lies mostly in programming and mission planning, part mods are allowed. Mods that do piloting other than kOS are disallowed. You can still use MechJeb info panels if you need. Notes on RemoteTech usage. Signal delay must be on. Antenna ranges must be in either in Root mode with RangeMultiplier = 0.5 or in Standard mode with RangeMultiplier = 1. Extra ground stations are allowed and their range may be increased to cover the whole Kerbol system. Number of ground stations is limited to 10. One set of extra stations can be found in the SETI pack. Missions beyond Kerbin SOI assume the existence of a relay network in Kerbin orbit. Otherwise, the launch of relay network must also be demonstrated if the mission relies on it. Scoring: Base score for each challenge is 100 points. Bonuses and penalties are applied in the form of score multipliers. Manual command penalty for all challenges: score x0.9 for every command entered in terminal after liftoff (command is a sentence ended with a period) Challenge list (The ones that have the description marked bold) V-2 Sputnik Corona Vostok Luna Syncom Molniya Gemini Surveyor Venera Mariner Apollo Viking Kerbal Positioning System Vega Cassini Falcon Mission descriptions: Mission badges Sputnik Vostok Luna
  17. I recently had another series, 2mF, developing a KOS script to automatically fly, return and land boosters in KSP. I decided to try that again, this time with less "empirically determined values" and with explaining my code. This should make the script fit to multiple different missions, not just this one specific rocket. I hope to be able to demonstrate New Shepard, Falcon 9 and Falcon Heavy like missions. This also is an editing-learning-experience for me. So I hope the audio quality on the next video will be better, I am trying! I want this to be a community-thing, so I am looking forward to your feedback, improvement suggestions and criticism! Links YouTube channel Forum Thread GitHub Repo Modlist CameraTools for recording DistantObjectEnhancement little dots for planets and ships PlanetShine planet illuminating the vessel Scatterer better atmosphere and water kOS programming rockets Other Info Text Editor Atom Syntax Theme Solarized Dark KSP Version 1.2.2 Video Editing Software Adobe Premiere Pro Microphone Blue Snowball Hans Episode #1: Automated Booster landing development tutorial using a KOS Autopilot script. Inaugural episode: Dumb suicide burn with a simple hop. I promise the audio will be better next time! Also go to the YouTube video, to like and subscribe!
  18. This is a very easy (but still hard), challenge, first and foremost the goals of the challenge. these are split into 5 levels. to progress onto the next level you must make an entry on all the levels before that e.g a level 5 entry needs a level 1, 2, 3 and 4 entry, if you get stuck go to the KOS documentation. the steps marked with an asterisk (*) are optional you do not need to complete that part of the challenge see below the goals of levels for the rules. level 1. 1. write a basic KOS script that gets a craft into orbit of kerbin, Gael or whatever kerbin-alike planet you wish. 2. write a KOS script to bring that same craft down from orbit. level 2. 1. write a script that can go to the Mun or any mun-alike body (hint: Vehicle must be like the saturn V with the conical fairing covering the LEM) 2. write a KOS script that can do a transreposition and docking (like on Apollo were they turned the CM around and docked with the LEM). 3. write a script that can do a insertion around that moon. level 3. 1. continuing on with the level 2 challenges you must write a KOS script that can land on the moon you are orbiting. 2. write a KOS script to ascend from that moon you have landed on. level 4. 1. write a KOS script to rendevous with the CM that is orbiting the moon (this level may qualify your name for a place in my signiture if it is a universal code). 2. create a KOS script that can dock. 3. retearn the spacecraft home from the moon. level 5. 1. create a KOS sciript that can go to Duna (or the planet packs equivelent) 2. land on duna. 3. go to ike (if it has a moon in the planet pack) 4. retearn to kerbin 4*. for extra credit, go to the moon. 5. re-enter safely and go home 5*. land near the KSC (100Km minimum) (Manley may be required ). secondly, the rules: (these are really simple rules). i know this challenge is possable because an old KOS dev did this challenge which is were insparation comes from this. 1. all parts mods are alowed (KOS is a requirement to complete this challenge). 2. don't cheat (no RO, or RSB without the stockalike patches) 3. KOS must control all aspects of the mission (Exept for EVA's and you actviating the scripts which is running the scripts from terminal). 4. most importantly, have fun coding these 5. you can use your old KOS scripts if you wish.
  19. Know this would suck up my gaming time from my 0.235 rescue mission, I've started playing 1.2, and doing it with kOS to boot. R&D has just started studies on mixed cycle engine, and fuselages larger than Mk2. The latest production jet engine, the J-X4 "Whiplash" Turbo Ramjet has allowed the creation of a more efficient Single Stage to Orbit Spaceplane than The Reliant (powered by the "Panther" and "Reliant" engines). This along with the new Shock Cone intake lead to the design and production of the 3rd SSTO model, with the ability to accelerate at higher altitudes. In order to keep the CoM somewhat centered after the majority of the propellant mass was used up, the Whiplash engines were placed on the wingtips, as far forwards as possible. This gave the craft a distinctive shape, leading to the name, "The Diamond." Also, the Design Department was sick of SR-71 knock-offs. After many launch "simulations," a good ascent profile was developed for The Diamond. This was programmed into a kOS sequencer, and consisted of 10 steps, including a drop in altitude to accelerate past 400 m/s to "jumpstart" the Whiplash. The SSTO was able to achieve an 80km orbit with about 500 m/s delta-V to spare or 150km with 380 m/s. A new de-orbit program was created, and 2 launches were performed with orbital altitudes of 80km, and 150km (to match the Curie Space Station). The Automated Landing Program originally made for The Reliant was used successfully both times resulting in safe landings at KSC. (vaguely sung to the tune of "The Bonnie Ship the Diamond" made popular by The Corries, though I prefer the Gaelic Storm version). The Diamond's a spaceship me lads, To orbit straight she's boun', At KSC she is all garnished with auto-struts aroun' Jebediah gives the order, To orbit far and wide, Where the Sun it oft'n sets me lads, And darkness dims the sky And it's cheer up me lads, ne'r yer struts be breakin' For the Bonnie Ship The Diamond goes a fishin' for kraken! (sorry, out of lyrics. Also, got a bit of help from /u/morpheus1229 on that last bit on the chorus) After the two shake-down cruises, The Diamond's first real mission came up. To prepare for the first landing on Minmus, Gene wants to bring down veteran Scientist and Engineer Bill and Bob from Curie Orbital Akademy and Gas Station. Also, we need one other redshirt. To help finance this operation, a Tourist Contract was accepted for an Orbital Adventure. (that's The Defiant attached in this older photo) En route to the station, Jebediah is tasked to capture an empty capsule or cabin, which will be converted to a re-entry pod at Curie. The Diamond seats 2 in the cockpit, and 2 in the cargo hold. With the addition of the re-entry pod, there's enough space for everyone that needs to go planet-side. And to get one more thing in, a "Rescue a Part" mission was also accepted. Previous attempts to KLAW the PAL Humpback Truss with the standard sized KLAW were unsuccessful. Mission Control hopes the new "Baby KLAW" (Tweakscale) will have better luck. That totals 5 Mission Objectives Retrieve 3 kerbals from Curie Orbital Akademy and Gas Station Retrieve an empty pod from Kerbin Orbit and bring to Curie Station Release the converted pod for re-entry (Bill thrown in there) Give a Tourist an orbital adventure Rescue a module from Kerbin Orbit The two orbital retrieval missions will require a number of Hohmann Transfers, using up precious fuel. The plan was to do a partial refuel at Curie. As you can see, all mission objectives were accomplished! Looks like the Landing Script couldn't stick the landing. I suspect with manually pumping fuel in, and after the Part Rescue, too little fuel was left, compared to the previous successful landing runs. This lead to some instability, which fed into the ascent/descent PID Loop in the landing program, causing pitching oscillations. Eventually the craft did a back-flip, one engine flamed out, leading to an accelerating upside-down flat spin. This actually slowed the fall down, likely due to the left generated (like Helicopter?). Descent speed was less than 50 m/s until fuel ran out near the ground. Most of the expensive parts survived, and they made it within 35 km of KSC. Val likes to point out she did better in her SSTO crash landing from Orbit.
  20. I'm trying to use the KAS winch with harpoon using kOS. I've been able to use events to extend and retract the cable, and with a little searching, detach the head from the ground. When I click Eject, everything goes well. The hook/head and cable fire out and attach to the ground (assuming it's in range) and then I assume the action taken when you click instant stretch takes place, making the length equal to the distance. Before it hits, the length is the maximum. However, calling the event to Eject only sets the length to max and unlocks/releases the hook (it remains attached to the cable), it doesn't fire out. Probably I'm doing something stupid, but what's the best/real way to do this?
  21. KOS basic scripts + crafts

    So I am playing with KOS and it's pretty hard to find some up to date tutorials (the documentation on github is fine! But Finding scripts that work or people willing to help isn't that easy) so I thought I'll just publish stuff I do and did here. Maybe someone else is just looking for a bump in the right direction or my future me thinks "how did I do that the last time?!". I'm a noob and teaching that stuff to myself is a whole new experience and I enjoy it. So this thread is where I'll dump stuff that works - maybe someone finds it usefull maybe someone posts something usefull. Have fun! Mods I used (wich are needed for the .craft files to load): - KOS (obviously) - MechJeb Crafts: 1. TKO (Tourists Kerbin Orbit) A rocket to bring 2 tourists into orbit and safely back to kerbin. picture: .craft file (just copy and paste into a editor and save as *.craft in saves/ships/VAB/*.craft) .ks file (script) (just copy and paste into a editor and save as *.ks in kerbal space program/ships/script/*.ks) It's a basic orbit script wich works nicely, has documentation and prints some stuff into your kos-terminal. 2. TKO (Tourist Knockout Suborbit) A rocket to bring a tourist to space and knock him out before bringing him back to the surface. picture: .craft file (just copy and paste into a editor and save as *.craft in saves/ships/VAB/*.craft) .ks file (script) (just copy and paste into a editor and save as *.ks in kerbal space program/ships/script/*.ks) This is as simple as it gets, no ifs, no loops - just a line of commands.
  22. I'm coming across what I think is a bug in Unity's font system that makes it hard for me to "be nice" to other mods and not break them. This problem is weird and what I've learned so far is from a few weeks of on/off trial and error and experimentation. I could be wrong about the cause, but I've barked up a lot of wrong trees already trying to find other possible causes before settling on what I'm about to describe below as what I think is the cause of it. So what's the problem? These two Unity methods Font.GetOSInstalledFontNames Font.CreateDynamicFontFromOSFont can break fonts that are also in a Resource/Asset file if these steps happen in this order: 1: Unity loads a font from Resource or Asset files, but hasn't had any occasion to draw anything in that font yet. 2: Using Font.CreateDynamicFontFromOSFont(), You create another Font instance that is for a font the same font family as the one from step 1 above (i.e. loading "Arial bold" when "Arial" was loaded in step 1.) 3: The font from step 2 (DynamicFontFromOSFont) gets rendered into some text. 4: The font from step 1 (From the Resources or Asset file) gets rendered into some text. When you do the steps in that order, then Unity gets confused and seems to wipe out all the glyphs of BOTH instances of that font from then on (i.e both the one from the Resources and the one from the OS). From now on it will render all text in that font as blank, (and it now claims that all text drawn in that font is 0 pixels wide and 0 pixels high, so things like GUILayout buttons get shrunken to minimum size in addition to not being able to show the labels on things because the font is blank.) Note that if you swap steps 3 and 4 so the Resources font gets exercised in some way before the DynamicFontFromOSFont does, the bug does not happen! It only happens when the first attempt to draw something in the font instance that was built from the OS font call happens prior to the first attempt to draw something in the Resources instance of that font. Note that it's the order in which the fonts get USED to draw something that matters here, not the order in which they first get loaded. (i.e. you can swap steps 1 and 2 and it doesn't change the outcome). As you can tell from the fact that I used "Arial" as my example case above, this means when we do this in kOS, I have the chance to break every other mod that uses Unity's default for something. Oh, and this isn't just about using the legacy IMGUI. I noticed that the act of using the font *anywhere* in Unity is affected, even when I draw 3D hovering text in Arial in the game scene - if the Arial font has had this bug trigger, then that 3D text won't show up. I can trigger the bug by choosing to render font text into a Texture2D in memory that I don't even show on screen anywhere. Even rendering it that way triggers the same problem so long as I do it in the order shown above. Why did I want to do this?: At this point, the person reading this might be thinking, "Well then just don't do it! Stop using the OS fonts and instead ship with one and hardcode it.") So I feel I have to defend my desire to support doing this: I'm trying to let the user use any font on their OS as the kOS terminal font, and move away from our current technique of cutting and pasting regions from a texture file that contains images of the 128 ASCII chars. (For 2 reasons: Using a real font scales a lot better than stretching a bitmap image for those users who prefer the terminal to use a bigger font, and more importantly it would let you print to the terminal in your preferred language, for which you probably already have a font you like installed on your computer that's better for that purpose than whatever we might ship with. But wait, isn't it only a conflict when you actually try to RENDER the font? Isn't the user just picking one font, not every font on the OS? True, but Unity does not expose any of the metadata about a font until after you load it, and even then you still have to actually render a few characters with it before all that you need to know manifests itself. If you haven't loaded a font from the OS yet, then the font's string name is literally the only thing you know about it. You don't know if it's bold, italic, etc (except from making a heuristic guess from looking for substrings in the font's name like "this font's name has the word 'bold' in it. I guess it must be a bold font then.". Most importantly for my case - you can't tell if it's monospace or proportional until after you load it and try rendering a few characters with it. The font metadata isn't available through Unity. So I was doing a quick dummy render of a short string containing some wide and some narrow characters, and counting the pixels Unity reported it took to do so to find out if it's monospaced or not. This is relevant since I use the font to paint a terminal very fast by drawing each line of the terminal as a single string - I need to restrict the picks the user is allowed to the monospace fonts only. It's that test for monospace that mandates that I actually give each font an experimental test render, and it's doing that which caused me to trigger the bug this post is talking about. I thought this would be really slow at first (test render every font) but it turns out that even on a computer with a few thousand fonts installed it only takes a couple of seconds, and I only have to do it once and then never again (and I can throw away the font after I tested it so it's not eating up memory once I learned it's proportional). So why not just avoid it by forcing the order to come out the "safe" way? An obvious fix presents itself: Before trying to use any Font that comes from CreateDynamicFontFromOSFont, kOS could just make sure to iterate over every Font object that ii finds in the Resources and perform a dummy rendering with each of them. (i.e. Tell it to render "Hello" into a Texture2D, then throw away the Texture2D, just to exercise the font a bit first which seems to prevent the bug.) I have tried that and it does work.... but... read on: I'm not in control of the order that OTHER mods do things in, nor am I in control of what order Unity chooses to call the Awake() and Start() methods of all the Monobehaviours from all the mods, nor am I in control of whether or not other mods might try to wait and lazy-load a font dynamically from an asset bundle later on during the game. This means there is no point in time when I can reliably answer "yes" to the question: "At this point have all the fonts that will ever get loaded, during the life of this process, from any Resource/Asset, been loaded and we know there will be no more?" In order to reliably use this workaround to fix the problem, I have to do so at a point in time when that is true, otherwise there will be a Resources/Asset font I missed when I performed the "foreach Resource font, render something small with it" code. So now to the questions for other modders: (1) How many mods actually bother trying to ship with their own font? Then again, with SQUAD doing localizations in the next release, who knows if maybe even THEY might wait to load a font later on after game initialization so I can't rely on knowing if they will do so. Could it be so few mods that the solution is to simply see if we happen to break another mod and if so then react to that and work with the other modder to come up with a scheme to force a known loading order between the fonts used by our two mods? (2) Do I need to consider splitting this work off into a standalone font manager mod and then make kOS require it as a dependency? Then any modder that wants to load fonts should have to work through it instead of doing it on their own? (i.e. similar to other library-mods like the CommunityResourcePack, the goal of such a mod would be to make sure all font loading happens in one place where the order can be enforced to prevent the bug.) (3) Any suggestions for a workaround that I might not have tried? I'm really not a Unity expert at all. The only things I know about it I know from doing kOS dev work. Yes, I am aware of the fact that Unity lazy-loads font glyphs (I found that out when trying to implement other parts of this system) and therefore the need to use Font.RequestCharactersInTexture() before attempting a test render to look at character size. But I suspect the bug above is somehow related to this lazy-loading feature misfiring in some way so the two different instances of the same-named font are stepping on each other's toes, or maybe Unity is getting fooled into thinking it already performed all the lazy-load work for both versions of the similarly named font when it really only did so for one of them. (Thus the font's data never gets populated because it thought it already did so?) (4) As KSP gets more international users, will more mods start considering using their own fonts so that even though this might not be a problem today it will become one soon so I still have to worry about it? (5) Is this a known Unity bug that was already fixed in a release of Unity but we don't have it yet because KSP is a few revisions behind? If so might the problem magically fix itself in the next KSP release? I tried searching Unity's issue tracker for font-related bugs and spent a long time walking through them and not finding anything that seemed related, before I gave up on trying to do that.
  23. I'd like kOS to calculate the velocity at periapsis for me with the apoapsis height, periapsis height and apoapsis velocity as variables. However, if one is using the specific orbital energy v2/2 - µ/r = constant, you must know the standard gravitational parameter. I could hardcode the values into my script for every celestial body, but I want it to be as general as possible (if you decide to alter the default masses with mods etc). How do I get rid of the dependency of µ in my formula?
  24. I have not been playing KSP a lot the last few years after I quit building space planes. Was a bit hard to find something fun to do motivating me to play but eventually I decided to use KOS and do some scripting. I cant code or script realy so that was interesting After doing some scripts that could take a specific rocket up in orbit or a spaceplane up and land I decided I needed something "Universal". Even with a handful of scripts and rockets when I played career with limited parts one have to invent rockets as the parts are unlocked so realy my new shiny rockets and there scripts where useless until the "end game". So I needed something that worked with most rockets. That is when I started to work on my "Universal Rocket Launch System" or URLS as I like to call it. Its written for KSP 1.2.2 and KOS, I suppose never versions "should work"? You can download the script here. The goal with the scrip is to put ANY payload in a 100-103km Low Kerbal Orbit. Now Im no programmer or scripted, And Im definitely not good at maths so my "formulas" might be a bit strange but they get the job done at least tough there not always as precise as I would like them to be. The script consist of a number of guidance modes. But basically the rockets pitch is calculated and set based on its altitude using a formula I created. The rockets velocity is calculated based of altitude to using a formula I derived and the engines are throttled accordingly to maintain proper acceleration trough the gravity turn. I actually derived my gravity turn formula used for the pitch with a rocket I called the Delta I. It could naturally do a gravity turn so I recorded that data, created a simple script that mimicked that and also tuned the thrust of the stages accordingly. Once I had this simple script I had enough data to create the gravity turn formula I mentioned earlier and the formula for the target velocity and all other formulas I needed. Now the problem is that not every rocket behaves like the one I used as a benchmark, the Delta I. The most common problem I noticed was either a to powerful first stage and a weak second stage and this created a problem. If the second stage is to weak aka low TWR it will not gain altitude fast enough, basically it will fall short of the intended profile of the gravity turn. Since the velocity is calculated based on altitude a second or 3:e stage could actually find it self costing at a pitch up attitude and just run out of fuel since the script did not demand full thrust because the orbital speed at that altitude was meet. As fare as the script was concerned the orbital velocity at that altitude was correct and sure it was but since vertical velocity was around zero the stage would just cost until the fuel ran out. So my next guidance mode I had to create is also based of altitude BUT the formula I derived calculates what time the rocket should be at that altitude. If we assume the rocket turns as programmed by she script and accelerates properly we should always know at what time our rocket should be at a specific altitude. So this secondary guidance mode basically calculates the time the rocket should be at Altitude X and it checks that against the time since launch and if we are ahead or behind to much this guidance mode takes control over the throttle. This mode wont allow the velocity of the rocket to go below 90% of the velocity that was the target, simple reason is that we dont want the rocket to fall out of the sky but other then that it can override the velocity as much as desired to "catch up". This secondary guidance mode will allow even a second or 3:e stage to coast in to orbit. Usually when the second or 3:e stage struggles to get in to orbit its usually enough just to move fuel from that stage to the previous stage, that gives more D/V on previous stage and a lighter second or 3:e stage giving them better TWR. The last guidance mode is basically there to put the rocket in LKO and this mode is activated either when the AP is deemed high enough or the rocket is high enough in orbit. To be able to understand what the script is doing I created a User Interface. It will show useful data the script uses and what guidance modes are in use and what part of the script has completed. This is very useful when designing a rocket to fly with the script. One can pretty easily determine if a stage has the proper TWR or not for example or adjust thrust limits on solid rocket boosters for example since the script has no control over those. I will now explain what the screen shows from top to bottom Apoapsis altitude - this is just apopasis altitude in meters so pretty strait forward Periapsis altitude - this is your periapsis altitude in meters. Vertical speed - this is your rockets vertical speed in m/s so useful to tune thruster limits and engine configurations. Vertical speed target - this is the vertical speed in m/s your rock should travel at the first 1000m after launch. Orbital Velocity - this is the orbital velocity in m/s of your rocket and its used for simplicity from launch to LKO. Velocity deviation - this shows the difference between the calculated velocity and the actual velocity in m/s the rocket is travelling at. Positive number and the rocket is going to fast and a negative number and the rocket is going to slow. Time in flight - this is the time the rocket has been flying since launch shown in seconds only. Deviation from ideal trajectory - this will show you how much behind or ahead in time in seconds the rocket is on its trajectory, ideally you want no deviation but some will eventually occur as the rockets vertical speed declines the accuracy is reduced. Target pitch - this shows the pitch the rocket is suppose to have not what it is, apparently it was very "hard" to script something that would show the rockets actual pitch so you should check this pitch value against the navball to make sure your rocket actually has the authority to pitch over as demanded. Then we have guidance modes. Only one guidance mode can have full authority at a time and what mode has authority will be shown with the word "Active" next to it. Vertical Velocity - This guidance mode is used the first 1000m of the accent, the rocket tries to go strait up and accelerate at a predetermined rate. Orbital Velocity - This is the primary guidance mode for the gravity turn and the one you want to spend most of the time in. It controls the velocity of the rocket according to altitude and should work for any rocket with good enough TWR. Time deviation - this is the secondary or fallback guidance mode. Its primary job is to take control from "Orbital Velocity" guidance mode if the rocket for example has an excessive TWR, like solid rocket boosters that was not properly configured with a thrust limit. Its more commonly activated when a second or 3:e stage has a to low TWR and it will make sure full throttle is used to try and coast the rocket in to orbit. I have also had instances where boosters smashed one of my main engines of and then this mode could save the rocket to. You dont realy want to be in this mode because then your rocket is not balanced to work well with the script but since this guidance mode is based on altitude it will be less accurate at say 50km or higher since the vertical speed decreases and the rockets starts to level of so even the best rockets might spend 10-20 sec in this mode before going in to the last guidance mode. This mode is also triggered if the rocket is 5 seconds behind or ahead of its intended point in time. Orbital Manoeuvrers - this is the last guidance mode and its basically there to get your in to LKO. It is activated either when the rocket has high enough altitude or when the AP is high enough. We dont want the AP to go higher then the intended LKO do we. The last part in our User Interface is Mission parameters. The word complete will be shown next to a mission parameter when it has been executed. Gravity turn - gravity turn is completed. LKO - rocket is in a stable Low Kerbal Orbit. Payload delivery - payload has be deployed. Deorbit burn - the orbital stage has done a retro burn and will now reenter Kerbin at 30km altitude and burn up. Now there area few other things that needs to be mentioned about the script. If an attribute in the User Interface reads "null" the that only means the data is no longer correct or available and therefore no data is shown to confuse the user. The script will check for engine flameouts and will stage as long as there are flamed out engines. The script will also check for active engines and stage until active engines are detected. Every time the rocket stage it will default to full thrust on the engines just to make sure it wont fall behind on its intended trajectory since the TWR will usually be lower with a new stage then an empty one. The scrip uses action group 10 to jettison faring or anything else you want to get rid of, this will happen at 54000m. If you want to jettison your faring earlier you can have that in your staging sequence as usual. The reason I opted for 54000m to jettison fairings is the the fact that I got destructive wobble with 3.75m parts up to about 50000m. Since the script is universal I need a safe altitude to deploy the fairings. The script will stage one last time in orbit to jettison then payload, but action group 9 is also triggered and can be used to separate a payload from the last stage and also extend antennas if you need an uplink to control the payload. Also the scripts formula to estimate velocity is a bit off in the early part of the gravity turn compared to the rocket it was designed for (Delta I) so its pretty common for it to report that the rocket is a bit behind in velocity but still show that the rocket is on time aka no Time Deviation. Try out the Delta II rocket supplied with the script for a good benchmark rocket to use as a reference. For the first stage I usually use a TWR of 1.5 based of the Vacuum numbers, if I use the atmospheric numbers I tend to go with 1.3. The scrip is primarily intended to make launches easy and routine and not to make them the most efficient to save that little bit of fuel. You should tune your rocket so it spends most time in the "orbital velocity" guidance mode for best performance but the script is intended to fly pretty much anything that can be flown manually tough its not designed for space shuttles. I have tested pretty much all my rockets, good and bad once and also most stock rockets in KSP and they do work (staging order might need tuning tough). You can download the script here. It will include the Delta II rocket (improved version of the Delta I but performance the same) and also a Soyuz ST (picture below) that I designed using the script. I would recommend flying them first to get an idea of how the script works and how you can use it to tune your rockets. So now its up to you to break my script and tell me what it cant do So feel free to post any good or bad launches in this thread.
  25. I tried my best with this video hope you liked it guys! Thanks