Jump to content

tobyb121

Members
  • Posts

    136
  • Joined

  • Last visited

Everything posted by tobyb121

  1. Is there any scope to develop on the land around the cities. In terms of realism I think they could do with some more residential areas and maybe a farm. You could also put some wind turbines around which could be fun to fly around.
  2. Most of that info is in FlightGlobals.ActiveVessel. All the altitude, heading, velocity information is in there. To get resources you can loop over all the parts in each vessel and count up their available resources.
  3. I believe all of the UI components are based on EZ GUI. The reference for UIButton is here: http://www.anbsoft.com/middleware/ezgui/docs/scripting/class_u_i_button.html Looks like you could try calling the OnInput method.
  4. Have a look at vessel.angularVelocity, it's a Vector3 so I would imagine that the x,y,z components are the angular velocities in x,y and z. Not sure if they are degrees/s or rad/s but that should be pretty easy to work out.
  5. Has anyone got any experiences extending the Knowledge Base, I'm setting out to build a set of science type part mods that will allow you to travel to a planet and for example take soil samples and see what the composition of the planet is. One of the main things I would like to do is make it so that you can view the data in the knowledge base, instead of building yet another custom UI. I'm aware that the knowledge base is likely to change quite significantly but I'll worry about that when it happens I've found there is a KnowledgeBase class with an Instance property that looks promising. Before I start poking around with this class, has anybody got any experience working with this class? While some of it seems reasonably self explanatory there are a few things that look like they could be fiddly, so thought I would see if anyone knew anything about it before starting work on it. Either way I'll try and document what I can and post the results. Tobyb121
  6. Hi I'm working on my first project and I've hit a bit of a block. I'm trying to build something like the chem cam on the Mars rover (it fires a high power lazer at rock and analyses the rock based on the spectrum). I've built my part model and it imports into ksp properly and I'm now working on the code. So far I've got my animations working and I can get it to draw a lazer when it's within range (20m) of a planet. I'm using a raycast to detect if I'm in range of the planet and then looking at the name of the transform of the associated collider mesh to find the name of the planet, then checking from a list of planets to see what the ray is colliding with. The problem I'm having is that I wanted to use colour of the texture at the pixel where the ray collides to generate the composition of the rock (so that for example if it was on duna and the colour was orange it would be silicon/iron based or it was white then it would ice or something), using something like this. I can get a reference to the texture using hitInfo.collider.renderer.sharedMaterial.mainTexture but when I then try and access the pixel data from it I get an error: UnityException: Texture 'KerbinScaledSpace300' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings. So it seems that my method isn't going to work. Does anyone have any idea of how else I might get the colour of the planet texture where my ship is? I'm thinking if I can't get it work I could use the latitude and logitude and make a low-res map of the minerals of a planet, but this will bloat the mod and probably won't give great results. This is the code I've got so far, the error comes at the line: Color col=tex.GetPixel(x,y); private void fireChemCam() { if (camState == ChemCamState.Open) { RaycastHit hitInfo; if (Physics.Raycast(lazerRenderer.transform.position, lazerRenderer.transform.forward, out hitInfo)) { string target = hitInfo.collider.gameObject.name; int planetId = PlanetNames.IndexOf(target); print("Collided With: " + target); Texture2D tex = hitInfo.collider.renderer.sharedMaterial.mainTexture as Texture2D; print("Texture Dims: "+tex.width.ToString()+", "+tex.height.ToString()); int x=tex.width*hitInfo.textureCoord.x; int y=tex.height*hitInfo.textureCoord.y; Color col=tex.GetPixel(x,y); print("R:"+col.r.ToString()+",G:"+col.g.ToString()+",B:"+col.b.ToString()); if (planetId>-1&&hitInfo.distance < 20 && (GetAvailableResource("ElectricCharge") >= 200)) { camState = ChemCamState.Firing; RequestResource("ElectricCharge", 200); lazerRenderer.enabled = true; _firing = 6; } } else _print("no Hit"); } } Any ideas would be greatly appreciated, Thanks in advance, tobyb121
×
×
  • Create New...