Jump to content

[WIP] KerbTown v0.13 Beta - Place static buildings, cities, launch sites & more!


Razchek

Recommended Posts

Tried it, didn't work. It was not the viewing distance nor anything else that stopped it, it was getting the kerbal to stay attached to the elevator all the way up and down. In my experiments he tended to fly out the elevator door at around 5000m, the only way I could get him past that was a very very slow elevator ride.

Were you using rigidbodys on the platform/walls of the elevator box??

Funny things happen with kerbals and static animations with normal colliders, some based on anim speed, some altitude. Most I have seen are solved by using rigids. Though I cant say Ive tested anything so high as a space elevator would need to be.

Link to comment
Share on other sites

Tried it, didn't work. It was not the viewing distance nor anything else that stopped it, it was getting the kerbal to stay attached to the elevator all the way up and down. In my experiments he tended to fly out the elevator door at around 5000m, the only way I could get him past that was a very very slow elevator ride.

I wasn't thinking about using it as an actual elevator, even though that would be totally awesome. I would be perfectly happy with the 'station' section where I can launch and/or dock stuff.

If using it as an animated elevator, what about attaching a chair for the kerbal to ride in?

Link to comment
Share on other sites

So, hypothetically speaking, one could import and place an orbital elevator object?

http://cache.gawkerassets.com/assets/images/8/2011/02/spaceelevatornice.jpg

If the object is parented to the ground hundreds of kilometers away would it even be possible to see it or interact with it in space (render distance)? Perhaps it could be broken into sections so that it can be seen at different altitudes with the high detailed launch/docking station at the top?

Level of Detail based on distance isn't implemented yet, but I will push that through if the KSP dev team incorporate it into PQSCity (if they don't do it anytime soon I'll write one up).

At the moment there is only one setting, and you can change the view distance in the config file after you've placed and object and saved the session. I should add that to the GUI lol.

Tried it, didn't work. It was not the viewing distance nor anything else that stopped it, it was getting the kerbal to stay attached to the elevator all the way up and down. In my experiments he tended to fly out the elevator door at around 5000m, the only way I could get him past that was a very very slow elevator ride.

You could.. it's a matter of updating the position of the ridigbody relative to the current position of the object at the selected offset.

I.e.

Put a transform as a child of the elevator. This will be the transform that the kerbal position will be updated to. (Could be the elevator platform?)

When a kerbal enters the elevator grab it's root transform component (and when it exits, let go of the component).

Now in update you would move the transform that you parented earlier to remain under the kerbal while it's in the elevator bounds.

Normally you would do this in LateUpdate or FixedUpdate, but update works better for the example below.

You would also (after moving the above transform) lerp the position of the kerbal to the same position as the transform.

Here's a rough example of moving the kerbal relative to the platform.

        private void Update()
{
Vector3 curPos = relativeTransform.position; // relativeTransform is the elevator platform.
Vector3 deltaVec = curPos - _lastPos; // _lastPos is an external field.

_lastPos = curPos;

foreach (DictionaryEntry d in _kerbalsOnPlatform) // Support multiple kerbals on the platform by putting them in a dictionary or table.
{
var kerbalData = (Data) d.Value;
Vector3 newPos = kerbalData.KTransform.position;
newPos += deltaVec;
kerbalData.KTransform.position = newPos;
}
}

This is jumpy, so you still need to lerp the move - but the example is a basic idea and it works (adapted from a resource I found on the net).

Make sure the platform is a kinematic rigidbody.

All moving objects should update the position of any objects that want to move with it.

If you wanted to be lazy, you could create a trigger collider and when the kerbal enters it you could parent it to the moving transform. Then when the kerbal exits you could remove the parent.

Remember velocity is going to be a factor on either of these solutions - so you'll need to handle them appropriately. :)

Edited by Razchek
Link to comment
Share on other sites

The Coriolis force shouldn't have any effect at the equator. (I assume the elevator was at the equator, since that's where KSC is.)

The reason Coriolis acceleration has little apparent effect at the equator is that it is getting canceled out by the two parts of the system on either side of the equator, and thus Coriolis acceleration does not cause the system to spin.

However, a Kerbal riding an equatorial beanstalk very much will be affected by Coriolis acceleration externally (internally: not much effect, for the above reason). In fact, Coriolis acceleration is at its strongest in the equatorial plane. A beanstalk at the poles would have no Coriolis acceleration (and be pretty useless for getting into orbit). Coriolis acceleration comes from the difference in lineal velocity at two different radii for the same angular velocity.

Link to comment
Share on other sites

Were you using rigidbodys on the platform/walls of the elevator box??

Funny things happen with kerbals and static animations with normal colliders, some based on anim speed, some altitude. Most I have seen are solved by using rigids. Though I cant say Ive tested anything so high as a space elevator would need to be.

Yep, tried it with everything.

The problem that I faced that I could not overcome was the speed at which the game itself can follow a kerbal. The camera would track the elevator to a certain height and then stop. I then went and used the lazor plugin (I think it was lazor) to allow the 2.5km viewing distance to be exceeded, but this did not have any effect on how fast or how far a camera will track a kerbal from a fixed position (the fixed position being the base of the elevator)

But I must say, all this talk has got me fired up again and I hate when I can't solve a problem, so I am now going to go test a new theory that I have... There are parts that did not exist in the game when I tried it last, so my hope is a command chair could solve my issue, Ill post results shortly. I also have some shots to post for something im making to donate to the kerbtown pack, just at work at the moment trying to get these last couple hours to go faster...

Link to comment
Share on other sites

Yep, tried it with everything.

The problem that I faced that I could not overcome was the speed at which the game itself can follow a kerbal. The camera would track the elevator to a certain height and then stop. I then went and used the lazor plugin (I think it was lazor) to allow the 2.5km viewing distance to be exceeded, but this did not have any effect on how fast or how far a camera will track a kerbal from a fixed position (the fixed position being the base of the elevator)

But I must say, all this talk has got me fired up again and I hate when I can't solve a problem, so I am now going to go test a new theory that I have... There are parts that did not exist in the game when I tried it last, so my hope is a command chair could solve my issue, Ill post results shortly. I also have some shots to post for something im making to donate to the kerbtown pack, just at work at the moment trying to get these last couple hours to go faster...

If you can make an orbital elevator, i would love you for ever and ever, no homo.

Link to comment
Share on other sites

None off the top of my head. Feel free to use the floating launch ground though. :P (Yeah, I know.. but it's just Proof of Concept)


I bring to you all an easter egg placed on Eve in update 0.11.3. No other changes were made for this update.

If you find the easter egg on Eve you're in for a nice surprise!! There are obstacles you must over come and a letter you must read at the end.

This Easter Egg will be tweaked but remain in the stable releases. Think of this as a pre-release viewing. :) The location is unlikely to change.

I hope you all enjoy the new content, and I look forward to hearing feedback.

And as always, keep posting the content you've been placing with KerbTown!!

Video preview for the Eve EE coming soon. :D

Link to comment
Share on other sites

I made a model and put it in the game, and it worked great. But I tried to make a custom plugin, and that didn't work at all. Here's what I have for the plugin:

using System;
using System.Linq;
using UnityEngine;
using KSP;
using KSP.IO;

namespace MassDriverNamespace
{
public class MassDriver : MonoBehaviour {
public string ObjectName = "";

public void Setup () {
print ("test");
GameObject gobj = (from t in gameObject.GetComponentsInChildren<Transform>()
where t.gameObject != null && t.gameObject.name == ObjectName
select t.gameObject).FirstOrDefault();
if (gobj == null) {
print("GameObject '" + ObjectName + "' could not be found.");
return;
}
var clickComponent = gobj.AddComponent<MScript>();
clickComponent.HighlightOnMouseOver = true;
}
}
public class MScript : MonoBehaviour {
public bool HighlightOnMouseOver = true;

private void OnMouseDown() {
print ("I clicked!!");
Vessel v = FlightGlobals.ActiveVessel;
v.SetWorldVelocity(new Vector3(0f,100f,0f));
}
private void OnMouseEnter() {
if (HighlightOnMouseOver) Highlight(gameObject, true);
}
private void OnMouseExit() {
if (HighlightOnMouseOver) Highlight(gameObject, false);
}
public void Highlight(GameObject sgameObject, bool highlightActive) {
if (sgameObject == null || sgameObject.renderer == null)
return;
sgameObject.renderer.material.SetFloat("_RimFalloff", 2.5f);
sgameObject.renderer.material.SetColor("_RimColor", highlightActive ? Color.green : Color.clear);
}
}
}

And I have this in my .cfg:

MODULE
{
namespace = MassDriverNamespace
name = MassDriver
}

Nothing ever gets printed, and it doesn't do anything if I click on it. What am I doing wrong?

Link to comment
Share on other sites

"Kerbal News at 11!:

All flights from Kerbal Space Center were suspended today when a massive bridge appeared and kerplunked onto the runway...more details as the story unfolds."

Nicely done sir! How big is that bridge??

Link to comment
Share on other sites

I made a model and put it in the game, and it worked great. But I tried to make a custom plugin, and that didn't work at all. Here's what I have for the plugin:

using System;
using System.Linq;
using UnityEngine;
using KSP;
using KSP.IO;

namespace MassDriverNamespace
{
public class MassDriver : MonoBehaviour {
public string ObjectName = "";

public void Setup () {
print ("test");
GameObject gobj = (from t in gameObject.GetComponentsInChildren<Transform>()
where t.gameObject != null && t.gameObject.name == ObjectName
select t.gameObject).FirstOrDefault();
if (gobj == null) {
print("GameObject '" + ObjectName + "' could not be found.");
return;
}
var clickComponent = gobj.AddComponent<MScript>();
clickComponent.HighlightOnMouseOver = true;
}
}
public class MScript : MonoBehaviour {
public bool HighlightOnMouseOver = true;

private void OnMouseDown() {
print ("I clicked!!");
Vessel v = FlightGlobals.ActiveVessel;
v.SetWorldVelocity(new Vector3(0f,100f,0f));
}
private void OnMouseEnter() {
if (HighlightOnMouseOver) Highlight(gameObject, true);
}
private void OnMouseExit() {
if (HighlightOnMouseOver) Highlight(gameObject, false);
}
public void Highlight(GameObject sgameObject, bool highlightActive) {
if (sgameObject == null || sgameObject.renderer == null)
return;
sgameObject.renderer.material.SetFloat("_RimFalloff", 2.5f);
sgameObject.renderer.material.SetColor("_RimColor", highlightActive ? Color.green : Color.clear);
}
}
}

And I have this in my .cfg:

MODULE
{
namespace = MassDriverNamespace
name = MassDriver
}

Nothing ever gets printed, and it doesn't do anything if I click on it. What am I doing wrong?

You might want to take a read of this to learn how to script with Unity: http://docs.unity3d.com/Documentation/Manual/CreatingAndUsingScripts.html

Because you were copying from my source code I think you missed out the fact that Setup() events are only executed in the main class for the built in modules.

It also looks like you're not looking for something to add the mouse script to. These members are referenced or executed after the built-in components have been added by KerbTown manually, rather than in the actual components.

For your own code, you should be writing the script as if it was any other script in Unity. Use Awake, Start, LateUpdate, Update, etc.. Take a read of the information available on the link above for a better understanding.

Anyway.. for the above to work you would add this into the MassDriver class:

void Start() { Setup(); }

And also you want to put the GameObject name into the ObjectName field value. Otherwise when the script is instantiated on your static object it will look for a GameObject with an empty name.

Good luck!


Btw, nice bridge Cooly568. :)

Link to comment
Share on other sites

"Kerbal News at 11!:

All flights from Kerbal Space Center were suspended today when a massive bridge appeared and kerplunked onto the runway...more details as the story unfolds."

Nicely done sir! How big is that bridge??

It's 30km long, and connects the mainland and the islands.

I need to get a better model for it though, as the current one kind of bugs out at its size.

Oh yeah and all of these models I'm posting are free models from the internet, so I will work stuff out before I distribute anything.

Link to comment
Share on other sites

It's 30km long, and connects the mainland and the islands.

I need to get a better model for it though, as the current one kind of bugs out at its size.

Oh yeah and all of these models I'm posting are free models from the internet, so I will work stuff out before I distribute anything.

Just scale that badboy down? Or will that mess with the road size to much?

Link to comment
Share on other sites

I'm working on place-able airport parts, and I've got a runway and a fuel pump up and running. The fuel pump functions very crudely for the moment, but I must say, creating KerbTown stuff was surprisingly painless. Thanks for creating this awesome tool, it saved me from having to invent a much sloppier version of it :)

I notice code runs on all placed objects regardless of whether they are in visual range of the active vessel, which must also mean they are all fully loaded. They probably don't create draw calls, since they are outside the cameras range, but have you done any work to allow for a custom load/unload range for placed entities, so that stuff on Duna doesn't take up memory or run code when you are on Kerbin?

Link to comment
Share on other sites

I'm working on place-able airport parts, and I've got a runway and a fuel pump up and running. The fuel pump functions very crudely for the moment, but I must say, creating KerbTown stuff was surprisingly painless. Thanks for creating this awesome tool, it saved me from having to invent a much sloppier version of it :)

I notice code runs on all placed objects regardless of whether they are in visual range of the active vessel, which must also mean they are all fully loaded. They probably don't create draw calls, since they are outside the cameras range, but have you done any work to allow for a custom load/unload range for placed entities, so that stuff on Duna doesn't take up memory or run code when you are on Kerbin?

Good question! It is implemented in my test builds but i'm still deciding on the best implementation method for release which is why you don't see it in the beta code yet.

My current test build implementation at the moment is to instantiate objects based on the current active SOI and then having the renderers and game objects enabled relative to the visibility range.

Infact it should even be possible with the native PQSCity class - but there have been issues when I've tested this.. so I'll have to do some more testing when I get time lol.

I will probably end up making it optional either in the code or config to allow flexibility. I'm sure someone will find a reason to have these persist even when they're not within visibility range haha.

Just on that note though. Script your timed solutions to work based on saved persistance and game time passed rather than running all the time lol.

Link to comment
Share on other sites

Good question! It is implemented in my test builds but i'm still deciding on the best implementation method for release which is why you don't see it in the beta code yet.

My current test build implementation at the moment is to instantiate objects based on the current active SOI and then having the renderers and game objects enabled relative to the visibility range.

Infact it should even be possible with the native PQSCity class - but there have been issues when I've tested this.. so I'll have to do some more testing when I get time lol.

I will probably end up making it optional either in the code or config to allow flexibility. I'm sure someone will find a reason to have these persist even when they're not within visibility range haha.

Just on that note though. Script your timed solutions to work based on saved persistance and game time passed rather than running all the time lol.

Per planet makes sense, but if people start adding lots of objects with scripts on them, maybe creating an extension of monobehvior to extend from that has an OnFixedUpdate or similar that only fires when in range would be good.

So the module would be


class FSgasPump : KerbtownBehavior // KerbtownBehavior : MonoBehavior
{
public void OnFixedUpdate()
{
Debug.Log("I know I'm in range, cause I'm called by KerbTown");
}
}

Well...guess I can throw my airports away now eh lol

Haha, this one is a small runway of dubious quality, kind of like the island runway. The main effort is the fuel pump, which I've had the model for for months. The plane is, when you get close, you have the option to fill up a selected tank with an amount, hopefully draining your cash reserves once that's in (I think I'll find the Kerbal wallet or make my own for testing purposes). I don't want to fill all tanks up automatically, cause that means my bomber with default 500 out of 1500 fuel filled won't take off.

Of course, oil rigs, kethane integration, solar farms that fill your batteries, all things are possible :)

Edited by Snjo
Link to comment
Share on other sites

Is there a way to change the maximum draw distance? I made a ring, but it disappears when I go more than 50km or so from KSC:

At the moment the only way to do this is to edit the config after you've saved the object:

	Instances
{
...
VisibilityRange = 100000 // 100,000 KM from the Local Vector3.zero to world of the static object.
...
}

Per planet makes sense, but if people start adding lots of objects with scripts on them, maybe creating an extension of monobehvior to extend from that has an OnFixedUpdate or similar that only fires when in range would be good.

So the module would be


class FSgasPump : KerbtownBehavior // KerbtownBehavior : MonoBehavior
{
public void OnFixedUpdate()
{
Debug.Log("I know I'm in range, cause I'm called by KerbTown");
}
}

Would people be keen on referencing KerbTown.dll in their projects though? I don't see why not, but I feel like I'd get a negative response for that lol.

Link to comment
Share on other sites

Would people be keen on referencing KerbTown.dll in their projects though? I don't see why not, but I feel like I'd get a negative response for that lol.

Well, as long as it's optional, it can only help. The modder can choose to extend a kerbtown class if they want to be sure their idea of active status matches up with kerbtown's active status. If there ends up being a whole decision tree for whether a static is active or not, it's better to listen to the result than trying to keep up to date with it through own code.

Of course there are many reasons not to be controlled by your code, like making interplanetary comm systems that are always on. Or making a space base fixed to a Lagrange point, constantly updating its position.

Link to comment
Share on other sites

Well, it seems that even if I set visibilityrange to something like 50000000, the objects get cutoff by the camera when I go more than 500km away or so. I wonder how we can see the Mün from Kerbin then?

Link to comment
Share on other sites

Maybe I'm missing something, but is there no way to retrieve the values used to create the static in a module on the static? Say I want to check what altitude and CelestialBody a static is at, a value used in placement, is that even stored in a module on the object, or is it just placed as an empty gameObject?

An extension like suggested above could include a reference to either the Kerbtown.KerbTown.StaticObject which has all the values, or have all the values given to it, like in a partmodule.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...