00:01
blowfish has quit [Quit: Leaving]
01:35
tfool has joined #kspmodding
01:37
Technicalfool_ has quit [Ping timeout: 204 seconds]
01:38
rsparkyc has quit [Quit: Leaving.]
02:07
SirKeplan is now known as SirKeplanzzz
02:53
Pap is now known as Pap|Away
03:01
NathanKell|Twitch is now known as NathanKell|AFK
05:07
NathanKell|AFK is now known as NathanKell
05:19
NathanKell is now known as NathanKell|Twitch
05:32
blowfish has joined #kspmodding
06:43
BasharMilesTeg_ has joined #kspmodding
06:49
BasharMilesTeg has quit [Ping timeout: 383 seconds]
07:02
BasharMilesTeg_ is now known as BasharMilesTeg
07:26
NathanKell|Twitch is now known as NathanKell|AWAY
07:28
blowfish has quit [Quit: Leaving]
08:19
ferram4 has quit [Ping timeout: 204 seconds]
08:37
<
Sigma88 >
I have a question about coding stuff in KSP
08:37
<
Sigma88 >
basically
08:37
<
Sigma88 >
Kerbin has a PQSCity mod called KSC
08:37
<
Sigma88 >
I can get that using:
08:37
<
Sigma88 >
FlightGlobals.GetHomeBody()?.GetComponentsInChildren<PQSCity>()?.First(m => m.name == "KSC");
08:38
<
Sigma88 >
then I can get the component "SpaceCenter" using this:
08:39
<
Sigma88 >
KSC.GetComponentsInChildren<SpaceCenter>().FirstOrDefault();
08:39
<
Sigma88 >
in some weird circumstances, using kopernicus, that component is null
08:40
<
Sigma88 >
my question is
08:40
<
Sigma88 >
how do I add a "SpaceCenter" component to the KSC PQSCity ?
08:40
<
Sigma88 >
I already have the component I want to add ( I can get it using SpaceCenter.Instance )
08:41
<
ninja81 >
If those are Unity components as I think they are... you can´t add a component to a component I think
08:42
<
ninja81 >
You have to add a GameObject somewhere
08:44
<
Sigma88 >
so I need to create a GameObject and then .AddComponent()
08:45
<
Sigma88 >
but how do I link the KSC and the SpaceCenter?
08:45
<
ninja81 >
A GameObject can be the parent of other GameObjects
08:46
<
ninja81 >
And into the GOs you add components
08:47
<
ninja81 >
The components are what tell Unity what the objects actually are
08:49
<
Sigma88 >
and to add a GameObject Child?
08:49
<
Sigma88 >
how would I do that?
08:50
<
Sigma88 >
GameObject doesn't have any "parent" or "child" as far as I can tell
08:50
<
Sigma88 >
I mean, there's no "AddChild()" or "SetParent()" method
08:50
<
Sigma88 >
I can only "GetChild()"
08:51
<
ninja81 >
I think you use AddComponent<Type> with GameObject or a type that ultimately inherits from it
08:52
<
Sigma88 >
so GameObject.AddComponent<GameObject>(myGO)
08:52
<
Sigma88 >
I'll try that
08:52
<
ninja81 >
Look in the KSP API for any classes in KSP that extend GameObject, too
08:54
<
ninja81 >
no problem
09:09
smoke_fumus has joined #kspmodding
09:10
smoke_fumus has quit [Client Quit]
09:10
<
Sigma88 >
so, it turns out that the the GameObject already exists
09:10
<
Sigma88 >
but it has the wrong parent
09:11
<
Sigma88 >
can I just change the parent?
09:11
<
Sigma88 >
or do I need to destroy that GameObject and create a new one?
09:11
<
ninja81 >
destroy and recreate
09:12
<
Sigma88 >
and if I destroy the GameObect I don't destroy the components in it right?
09:13
<
ninja81 >
Probably does, unless maybe you got a reference first
09:17
SirKeplanzzz has quit [Ping timeout: 204 seconds]
09:17
SirKeplan has joined #kspmodding
09:18
<
Sigma88 >
I could try adding a new object with the components I need first
09:18
<
Sigma88 >
and then delete the old object?
09:19
<
ninja81 >
I suppose... if you can actually clone them
09:23
<
Sigma88 >
I can't add a GameObject using AddComponent
09:29
<
Sigma88 >
yes I was starting to look for that kind of stuff
09:32
<
Sigma88 >
GameObject.transform.parent
09:32
<
Sigma88 >
I think that's it
09:33
<
ninja81 >
a transform is the XYZ coordinates of the object.. its parent is the object
09:37
<
Sigma88 >
they say to do: this.transform.parent = yourParentObject;
09:49
<
Sigma88 >
(which seems to work)
09:51
<
Sigma88 >
even tho sadly it doesn't fix my issue >_>
10:16
TriggerAu has joined #kspmodding
10:33
TriggerAu has quit [Ping timeout: 201 seconds]
10:34
TriggerAu has joined #kspmodding
11:35
<
taniwha >
Sigma88: of course you can't use addcomponent to create a gameobject
11:35
<
taniwha >
addcomponent adds a component to a gameobject
11:36
<
taniwha >
Sigma88: plaque = new GameObject ("Survey Plaque");
11:36
<
taniwha >
it's as simple as that :)
11:36
<
taniwha >
or as complicated as GameObject go = new GameObject ("Survey Plaque Canvas", typeof (RectTransform), typeof (Canvas), typeof (CanvasScaler));
11:37
<
Sigma88 >
and to parent it I just need to do go.transform.parent = whatever ?
11:37
<
taniwha >
er, except, there's a better way
11:38
<
taniwha >
transform.SetParent (parenttransform, true/false)
11:38
<
taniwha >
SetParent gives you more control over the coords
11:38
<
taniwha >
iirc, the param is useWorldCoords
11:39
<
taniwha >
rxform.SetParent (plaque.transform, false); from EL
11:39
<
taniwha >
RectTransform rxform = go.transform as RectTransform;
11:39
<
taniwha >
(last two lines reversed)
11:44
<
taniwha >
you're welcome. I hope it helps
11:44
<
Sigma88 >
the problem is, I don't even know what is breaking :D
11:44
<
taniwha >
the RectTransform stuff is for 2d ui stuff
11:45
<
taniwha >
Debug.LogFormat is your friend :)
11:47
<
Sigma88 >
as far as I can tell
11:47
<
Sigma88 >
when Kopernicus makes a clone of Kerbin
11:47
<
Sigma88 >
it also clones the KSC stuff
11:48
<
Sigma88 >
which messes up KSP since it only expects to find one
11:48
<
Sigma88 >
the funny thing is that if the game bugs out only if the kerbin clone is closer to the sun than the home planet
11:48
<
taniwha >
ok, so yes, when you clone, you'll need to dig through the clone and remove or rename the ksc stuff
11:49
<
taniwha >
that's not all that funny when you think about it
11:49
<
Sigma88 >
that's funny because it means that squad probably uses "First"
11:49
<
taniwha >
if the planets are listed in order of distance from the sun, then the closest one will be found
11:49
<
Sigma88 >
assuming there's only one
11:49
<
taniwha >
and the search will stop there
11:50
<
taniwha >
anyway, when cloning, remove or rename the ksc stuff
11:50
<
Sigma88 >
that's for thomas to do
11:50
<
Sigma88 >
I don't really understand that part of the code
11:50
<
Sigma88 >
but I think as a temporary bodge I can try to reparent the KSC object to Kerbin
11:50
<
Sigma88 >
maybe that works
11:52
<
taniwha >
just dig through the clone's hierarchy looking for KSC
11:59
<
Sigma88 >
that's what I'm doing
11:59
<
Sigma88 >
the problem is that when I get there KSP already has decided that the clone is the proper KSC
12:10
<
taniwha >
and when do you get there?
12:13
Thomas|AWAY is now known as Thomas
12:18
<
Sigma88 >
I'm trying a different approach now
12:37
NotFrom4chan has joined #kspmodding
12:41
Pap|Away is now known as Pap
13:45
<
NotFrom4chan >
ASET seems to be broken for whatever reason. the Flip-Up HUD causes a JSIvariableAnimator initialization failure
15:28
Ezriilc has joined #kspmodding
15:34
smoke_fumus has joined #kspmodding
17:05
ferram4 has joined #kspmodding
18:28
regex has joined #kspmodding
19:08
tfool has quit [Read error: Connection reset by peer]
19:44
regex has quit [Ping timeout: 201 seconds]
19:45
Thomas is now known as Thomas|AWAY
19:58
regex has joined #kspmodding
21:09
blowfish has joined #kspmodding
21:21
regex has quit [Remote host closed the connection]