- Home /
Wiring Script & Relaying Messages
I'm playing around with some prototype game ideas and one I have involves simulating the wiring of equipment around a ship. The most similar practical example of this is the Wire Mod in GarrysMod, which allows one to hook up 'power' to various objects in the game.
I've drawn a small picture of what I mean in order to get the idea across:
The idea I have right now is to create a GameObject "WireNode". The Gameobject will be fairly typical - A model representing a wiring junction. The non-typical thing I want to develop is a script that controls the junction points A, B and C.
What I have in mind I think is quite simple: Each junction point is simply a message relay. By default everything is unconnected but if you get a device to the junction point any messages from the device are simply relayed onward until it hits another device and its actioned there. If there is a dead-end nothing happens (Or maybe a 'spark'). The idea here is that I can send 'power' or any other message between parts of the ship and simulate disconnections and whatnot.
I want the player to physically take a softbody wire (Or some sort of articulated rigidbody) and perform the connections.
What I'm looking for here is some feedback on the implementation of the idea, and any resources you think might help me. I'm a few months into Unity dev so I know a fair bit but definitely not everything:
I've yet to fully explore the messaging and event systems available in Unity so some information on that would be great. EDIT: On further consideration I think I'm going to use C# Events to pass between the junction points.
I'd like the implementation of the wires themselves to behave a lot like the softbody wire-plugs in Half-Life 2. So any resources towards snapping objects to things (Physics attractors?) and rope physics would be great.
I'm a bit vague on how to program the connection between the wire object and two relays - Not sure how I would do that?
Any other general feedback welcome.
Thanks!