Trouble spawning a switch
I am spawning a switch but the input and outputs are not spawning on the switch....

               ElectricSwitch switch1;

               switch1 = GameManager.server.CreateEntity("assets/prefabs/io/electric/switches/simpleswitch/simpleswitch.prefab") as ElectricSwitch;
               switch1.SetParent(box1, box1.GetSlotAnchorName(BaseEntity.Slot.Lock));
               switch1.transform.localPosition = new Vector3(-1f, -1f, 0f);
               switch1.transform.localRotation = Quaternion.Euler(new Vector3(0, 270, 0));

                switch1.Spawn();​
Seems the setparent is only moving the inputs and not the hole switch?
This sounds like an issue I'm having. The same thing happens when I try to attach a wooden box to a minicopter, the box always works, but the rendered model sometimes doesn't show up or freezes in place. I think the problem in my case is that the client doesn't expect a box model to move, so it keeps rendering it in it's original position until it gets an update or something. I still haven't found a solution.
instead of a box have you trued using a small stash?
Ts3hosting
Seems the setparent is only moving the inputs and not the hole switch?

I'm attaching a switch to a car, basically the same way, and it can be wired.  The positioning might be interfering with the wiring tool.  Try putting the switch a few feet above the minicopter and see if it can be wired there.  I'm also destroying the switch's collider, but I don't think that would affect the wiring.

andrew2085
This sounds like an issue I'm having. The same thing happens when I try to attach a wooden box to a minicopter, the box always works, but the rendered model sometimes doesn't show up or freezes in place. I think the problem in my case is that the client doesn't expect a box model to move, so it keeps rendering it in it's original position until it gets an update or something. I still haven't found a solution.

I ran into something like that when putting search lights on minicopters.  Fixed it by running ".SendNetworkUpdate(BasePlayer.NetworkQueue.Update);" on the search light, inside the minicopter's FixedUpdate().  Maybe give that a try.



Merged post

Perhaps it wouldn't be an issue if you could wire the switch automatically.  Here's how to connect a wire from one electrical item to another. 

		private void RunWire(IOEntity source, int s_slot, IOEntity destination, int d_slot)
		{
			destination.inputs[d_slot].connectedTo.Set(source);
			destination.inputs[d_slot].connectedToSlot = s_slot;
			destination.inputs[d_slot].connectedTo.Init();
			source.outputs[s_slot].connectedTo.Set(destination);
			source.outputs[s_slot].connectedToSlot = d_slot;
			source.outputs[s_slot].connectedTo.Init();
			source.MarkDirtyForceUpdateOutputs();
			source.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
			destination.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
		}​
Ya still no go if i attach the switch to anything and move it to far from the spawn point it disapears/invisable.
I have been playing around with spawning pianos in RHIBs and scrap helis, they become invisible after driving around but the colliders are still there. I've been told it's an issue with Rust culling.
And even weirder, if I /remove, ent kill or destroy anything near the piano vehicle the piano gets destroyed.
The piano getting destroyed might be a 'ground check' that runs when nearby stuff gets killed.   Check for 'DestroyOnGroundMissing'.  Or kill it like this:

UnityEngine.Object.Destroy(entity.GetComponent<DestroyOnGroundMissing>());​


Also, there is a workaround for the culling issue.  The game doesn't expect certain entities to move, so if you go a certain distance from where it was spawned, it stops showing up to the players.  The trick is to not attach it to the entity that you want it attached to.  Instead spawn it in the middle of nowhere and move it each frame to where you want it.  I call it 'pseudo attachment'.

That's how I got advanced Christmas lights to stick to the Chinook.
Can you show example of your pseudo attachment

Merged post

shotgun traps the same thing disapear.
I don't want to post what I wrote, it's a mess and has some bugs.  And there's got to be a better way.

For what it's worth, the entity is still there.  The client just doesn't draw it.

Maybe a good balance would be to set a timer that kills and respawns the entity every once in a while, if its position has changed enough.
Ya May Be in a mono.

Merged post

Set parent null then reset parent on a timer seems to keep it with the parent item.
I'll have to give that a try.  Much more efficient.

hey guys, did any of you find a final solution to this issue? having the same problems adding prefabs to helis.

thanks