Quantcast
Channel: Questions in topic: "pipe"
Viewing all 89 articles
Browse latest View live

ReadLine from Named Pipe freezes Unity

$
0
0
Hi everyone. I've got a problem which is that ReadLine method (StreamReader) freezes Unity when trying to read from a named pipe and that happens just after I start the game or to be more precise when I start to read. I need to receive as well as send messages using the pipe to another process and ideally I would like to be able to listen to the pipe constantly and send a message at any time. Here's my code: using UnityEngine; using System.Collections; using System.IO.Pipes; using System.IO; public class WEB_HANDLER : MonoBehaviour { private string pipeName { get { return "PIPE"; } } private NamedPipeClientStream stream; private StreamWriter sw; private StreamReader sr; void Start() { //Starting the pipe Debug.LogFormat("[IPC] Creating new ClientStream. Pipe name: {0}", pipeName); stream = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut); //Connecting to the pipe Debug.Log("[IPC] Connecting..."); stream.Connect(120); Debug.Log("[IPC] Connected"); //Initialising Readers/Writers Debug.Log("[IPC] Starting StreamReader"); sr = new StreamReader(stream); Debug.Log("[IPC] Starting StreamWriter"); sw = new StreamWriter(stream); //AutoFlush Debug.Log("[IPC] AutoFlush = true"); sw.AutoFlush = true; Debug.Log("[IPC] Starting listening coroutine"); StartCoroutine(Listen()); } void Update() { //Sending messages to the pipe if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("[IPC] Sending message to server"); sw.WriteLine("Test message"); Debug.Log("[IPC] Success"); } } IEnumerator Listen() { while (true) { string message = sr.ReadLine(); if (message.Length > 0) //If message is not empty then print it { Debug.Log(message); } yield return new WaitForEndOfFrame(); } } My guess is that I'm reading an empty string and there is no escape sequence in it so it keeps on reading nothing. If I'm right, how can I solve the problem?

How do i make Pipe game, looks like Rocket Mania from Game House?

$
0
0
I was planning make a game that looks like Rocket Mania and it almost done. I'm using OnTriggerEnter2D to check the pipes to add into the List. But something was wrong when i try to remove or clear the List using OnTriggerExit2D (somehow if the player rotate the pipe to the other pipe). It looks like sometimes the collider detects other pipe, but sometimes it does not. ![alt text][1] public bool isConnectAll = false; public GameObject [] newObstacle; public float speed = 0.001f; int obj = 0; Vector3 posObs; //Vector3 posObs2; private Transform posY; public List Obstacle = new List(); void Start () { } void Update () { if (isConnectAll == true){ for (obj = 0; obj < Obstacle.Count; obj++) { posObs = new Vector3 (Obstacle[obj].transform.position.x, Obstacle[obj].transform.position.y, Obstacle[obj].transform.position.z); //posObs2 = new Vector3 (Obstacle[obj].transform.position.x, Obstacle[obj].transform.position.y, Obstacle[obj].transform.position.z); Destroy(Obstacle[obj]); SpawnObs(); //StartCoroutine(secondBetween(1)); } Obstacle.Clear(); isConnectAll = false; } } void OnTriggerEnter2D(Collider2D other){ if (other.tag == "Balok"){ Obstacle.Add(other.transform.parent.gameObject); other.transform.parent.GetComponent().Check = this; } } void OnTriggerExit2D(Collider2D other){ if (other.tag == "Balok"){ Obstacle.Remove(other.transform.parent.gameObject); other.transform.parent.GetComponent().Check = null; Obstacle.Clear(); } } public void SpawnObs(){ int i = Random.Range(0,newObstacle.Length); Instantiate (newObstacle[i], posObs, Quaternion.identity); } IEnumerator secondBetween(int second){ yield return new WaitForSeconds(second); } Or maybe you guys please help me to make this game out. Maybe with the other way? [1]: /storage/temp/71208-pipe.png

Liquid flowing through pipe?

$
0
0
Hello developers, Im searching for a good way to simulate liquids flowing through pipes, so, if you have some experience with it please share it ^^

Unhandled exception crashes the game : A heap has been corrupted

$
0
0
Hello, I make a Windows game that uses **named pipes** to communicate with the outside. I can successfully receive data, but **the game keeps crashing when I send ~5 messages** (yes, 4 is fine but the fifth one makes everything crash, even if messages are identical.. I don't know why). What happens is a small delay of a second and then the game just closes itself, with no information. **I tried :** - Running a "development build" standalone, but the error is not catched into the output log. - Different ways of sending my message (ASync, normal, by disposing NamedPipeClientStream ...) unsuccessfull. - Running from the Editor. In this case I can use Visual Studio to debug and I get the error > "Unhandled exception at ......> (ntdll.dll) in Unity.exe: .....: A> heap has been corrupted (parameters:> ....)." I have no idea what is happening here. My hypothesis is that unity's System.IO.Pipes is broken. I would like to find a workaround or if possible to ignore this error. I am already using try-catch when sending messages and it seems like it does nothing. When running from the editor and debugging with VS, I was able to ignore the error and continue the execution. Maybe I can do that to automatically ? Here is the send method I use now : public void send(PipeMessage message) { try { pipeClient = new NamedPipeClientStream(".", sendPipeName, PipeDirection.Out, PipeOptions.Asynchronous); pipeClient.Connect(timeOut); pipeClient.BeginWrite(message.bytes, 0, message.bytes.Length, aSyncSend, pipeClient); } catch (Exception e) { } } private void aSyncSend(IAsyncResult iar) { try { NamedPipeClientStream sApipeClient = (NamedPipeClientStream)iar.AsyncState; sApipeClient.EndWrite(iar); sApipeClient.Flush(); } catch (Exception e) { } }

simple namedpipe code not working as expected

$
0
0
Hi, I'm trying to get familiar with named pipes in Unity. To get started I ave a simple test program where the server sends '1' to the client, and the client sends '2' to the server. I got the program running for two console application. Now I want Unity to communicate with my console application. I have the following code. The console application: using System; using System.Text; using System.IO.Pipes; namespace PipeSample { class Program { static void Main(string[] args) { using (NamedPipeServerStream namedPipeServer = new NamedPipeServerStream("test_pipe",PipeDirection.InOut)) { Console.WriteLine("Waiting for connection on named pipe"); namedPipeServer.WaitForConnection(); namedPipeServer.WriteByte(1); int byteFromClient = namedPipeServer.ReadByte(); Console.WriteLine(byteFromClient); } Console.ReadLine(); } } } Unity Code: using UnityEngine; using System.Collections; using System.IO.Pipes; public class PipeWork : MonoBehaviour { void ReceiveByteAndRespond() { using (NamedPipeClientStream clientStream = new NamedPipeClientStream("test_pipe")) { clientStream.Connect(); Debug.Log(clientStream.ReadByte()); clientStream.WriteByte(2); } } void Update() { if (Input.GetKeyDown(KeyCode.Space)) { ReceiveByteAndRespond(); } } } So when I run the code and press space, in the Unity console I see '1' as expected. Unfortunately in the console application I see '1' too after some delay. Can somebody explain to me why this happens?

Infinite loop with named pipes

$
0
0
Hello everyone, I'm currently trying to implement a threaded IPC service with named pipes in PipeTransmissionMode.Message. When reading received messages from the server stream, the thread gets stuck in an infinite loop because IsMessageComplete never evaluates to true. The problem occurs in Unity 5.6.1f1 as well as 2007.1, but not in a .NET 4.5.2 console application using the identical code. Having spent a whole day on trying to figure this out I'd very much appreciate if someone could point me in the right direction. I'm not sure if I'm doing something wrong or this is a bug in Unity. Here is a minimal working example: using UnityEngine; using System.IO.Pipes; using System.Threading; using System.Text; using System.IO; public class MinimalPipeExample : MonoBehaviour { public string pipe = "MinimalPipeExamplePipe"; void Start() { new Thread(runServer).Start(); Thread.Sleep(1000); // wait until the server is running using (NamedPipeClientStream cs = new NamedPipeClientStream(".", pipe, PipeDirection.Out)) { cs.Connect(); byte[] message = Encoding.UTF8.GetBytes("Hello World"); cs.Write(message, 0, message.Length); cs.Flush(); Debug.Log("C Message sent"); } } void runServer() { using (NamedPipeServerStream ss = new NamedPipeServerStream(pipe, PipeDirection.In, 1, PipeTransmissionMode.Message)) { ss.WaitForConnection(); MemoryStream ms = new MemoryStream(); byte[] buffer = new byte[32]; do { int bytesReceived = ss.Read(buffer, 0, buffer.Length); ms.Write(buffer, 0, bytesReceived); Debug.Log("S Some bytes read; message complete: " + ss.IsMessageComplete); // infinite loop here because IsMessageComplete is never true } while (!ss.IsMessageComplete); Debug.Log("S Message received: " + Encoding.UTF8.GetString(ms.ToArray())); } } }

UTF8 string acquired through NAMEDPIPES unrecognized by Unityengine

$
0
0
Hi, the problem is quite simple yet I can't find a solution. I have a string value "sam" that I send through named pipes to my unity application. I receive the string and can print it in the log without issues, but if I use that string to compare with another string of same value created in unity itself (using IF or SWITCH functions), unity finds they don't match. My code, server side (Winform app): dataWriter("sam"); void dataWriter(string dataToSend) { byte[] _buffer = Encoding.UTF8.GetBytes(dataToSend); pipeServer.BeginWrite(_buffer, 0, _buffer.Length, new AsyncCallback(asyncWriter), pipeServer); } private void asyncWriter(IAsyncResult result) { pipeServer = (NamedPipeServerStream)result.AsyncState; pipeServer.EndWrite(result); pipeServer.WaitForPipeDrain(); pipeServer.Flush(); } On the client side (unity app) : if (pipeStream.IsConnected) { Debug.Log("Start Reading"); pipeStream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(readCallBack), pipeStream); } private void readCallBack(IAsyncResult result) { pipeStream.EndRead(result); string stringData = Encoding.UTF8.GetString(buffer, 0, buffer.Length); Debug.Log("Data received : " + stringData); /// Will successfully print "Data received : sam" in unity logs if (stringData == "sam") //// Will be FALSE { Debug.Log("Data received = sam"); } else { Debug.Log("Data received does not equal SAM "); // Will print this, because it finds stringData is not equal to "sam" } } I tried alot of things: change the encoding format, tried to transform the IF variable from string to byte to string using UTF8 encoding in hopes of having the same string as the data received, tried to trim the BOM from the string if there was any but apparently there is none already, etc. Please save me from hell on earth!!

super mario pipe physics?

$
0
0

i wanna know how you would be able to stand on a certain object(pipe), and press the down key to enter it? Could someone please help? any help will be greatly appreciated!


How best to make long pipes/cables in unity?

$
0
0

Hi,

I am working on an educational game that allows museum visitors to explore various undersea environments. One of these environments is the undersea portion of an oil rig.

http://a5.sphotos.ak.fbcdn.net/hphotos-ak-snc4/58056_10150339222165467_431744650466_16137589_7115424_n.jpg

I have or can create models representing the various undersea well heads and components, and these are easy to place into a unity terrain, but I need to connect them to long pipelines that eventually lead up to the surface. I am trying to figure out the best way to do this. These are big heavy pipes, so they don't really need any physics to them. Colliders would be nice, but not absolutely necessary.

From my searches it seems like the best way to do this, may be a line or tube renderer:http://www.unifycommunity.com/wiki/index.php?title=TubeRenderer

Unfortunately, both of these require very large arrays of vector3s which I can't find an easy way to create. I would like to be able to draw a smooth vector spline into 3d space, and render it either as a shaded, or preferably a dimensional tube, and be able to tweak positioning in unity.

The other way, I guess would be to make the pipes all in a 3d program and import them in as meshes. This might be better, but it would be hard to precisely connect them to the other models in unity, and have them lie along the bottom of the unity terrain.

Any suggestions?

Thanks,

-Matt

convert c# code for unity return errors

$
0
0
I try to run c# in unity but I got errors: - error CS0234: The type or namespace name `Pipes' does not exist in the namespace `System.IO'. Are you missing an assembly reference? - error CS0234: The type or namespace name `Unix' does not exist in the namespace `Mono'. Are you missing an assembly reference? How I can to convert the code to something that run on Unity? code: using System; using System.IO; using System.IO.Pipes; using System.Net; using System.Net.Sockets; using System.Xml; #if __MonoCS__ using Mono.Unix; #endif namespace Mumble { public class Mumble { protected NamedPipeClientStream pipe; protected StreamReader sr; protected StreamWriter sw; public Mumble() { #if __MonoCS__ Socket s = new Socket(AddressFamily.Unix, SocketType.Stream, 0); UnixEndPoint ue = new UnixEndPoint(Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "/.MumbleSocket"); s.Connect(ue); NetworkStream pipe = new NetworkStream(s); #else pipe = new NamedPipeClientStream("Mumble"); pipe.Connect(); #endif sr = new StreamReader(pipe); sw = new StreamWriter(pipe); } private bool OutputStringReply() { String line; while ((line = sr.ReadLine()) != "") { Console.WriteLine(line); } return true; } private bool ReadReply() { bool reply; using (XmlReader xr = XmlReader.Create(sr)) { xr.MoveToContent(); xr.ReadToDescendant("succeeded"); reply = xr.ReadElementContentAsBoolean(); } return reply; } public bool Mute(bool state) { sw.WriteLine("", state); sw.Flush(); return ReadReply(); } public bool Deaf(bool state) { sw.WriteLine("", state); sw.Flush(); return ReadReply(); } public bool Focus() { sw.WriteLine(""); sw.Flush(); return ReadReply(); } public bool OpenUrl(String url) { Uri u; Uri.TryCreate(url, UriKind.Absolute, out u); sw.WriteLine("{0}", u); sw.Flush(); return ReadReply(); } public String QueryUrl() { sw.WriteLine(""); sw.Flush(); String reply; using (XmlReader xr = XmlReader.Create(sr)) { xr.MoveToContent(); xr.ReadToDescendant("href"); reply = xr.ReadString(); } return reply; } /* public static void Main(String[] args) { Mumble m = new Mumble(); m.Deaf(true); } */ } }

Using Pipes/Streams Freezes Unity

$
0
0
Hello, So I'm trying to get two processes to communicate with each other. Specifically a Visual C# Program that does something and sends strings through the pipe as it does it, and a Unity C# script which receives those messages. The problem is that unity, whenever I run this script (Included below) freezes and nothing happens. For the sake of testing there is an empty Unity Game Object that only has the script in it. If anyone knows anything about this problem, or can help me out, that would be very helpful. I'm using these programs from MSDN for reference on how to communicate using Pipes in C#: http://msdn.microsoft.com/en-us/library/bb546102.aspx using UnityEngine; using System.Collections; using System.IO; using System.IO.Pipes; using System.Diagnostics; public class iPhoneCommunicator : MonoBehaviour { Process pipeClient; AnonymousPipeServerStream pipeServer; public void Start(){ Console.WriteLine("Hello, World!"); pipeClient = new Process(); // Point the program to the executable pipeClient.StartInfo.FileName = "C:\\Users\\Eugene\\Briefcase\\School Documents\\CSE 4904 - Senior Design\\src\\TeamB-Code\\AirControl\\AirControlServerWindows\\AirControlServerAlpha\\bin\\Debug\\AirControlTest.exe"; // Initialize the Server Stream pipeServer = new AnonymousPipeServerStream(PipeDirection.In,HandleInheritability.Inheritable); //Set Transmission mode to bytes, since messages are not accepted pipeServer.ReadMode = PipeTransmissionMode.Byte; // Pass the client process a handle to the server. pipeClient.StartInfo.Arguments = pipeServer.GetClientHandleAsString(); // Disable Console output for the client pipeClient.StartInfo.UseShellExecute = false; // Start the client pipeClient.Start(); pipeServer.DisposeLocalCopyOfClientHandle(); } public void Update(){ Console.WriteLine("Updating"); using (StreamReader sr = new StreamReader(pipeServer)) { // Display the read text to the console string temp; // Wait for 'sync message' from the server. //Synchronize with the client, wait for a "SYNC" message do { Console.WriteLine("[SERVER] Wait for sync..."); temp = sr.ReadLine(); } while (!temp.StartsWith("SYNC")); // Read the server data and echo to the console. while ((temp = sr.ReadLine()) != null) { Console.WriteLine("[SERVER] Echo: " + temp); } } } } public static class Console { public static void WriteLine(System.Object obj){ UnityEngine.Debug.Log(obj.ToString()); } public static void WriteError(System.Object obj){ UnityEngine.Debug.LogError(obj.ToString()); } }

How do I get named pipes to work in Unity?

$
0
0
Hello, I've been trying to used named pipes in order to send data from one application to Unity, and I was thinking that named pipes would be a good idea. However, whenever I try creating the Server, I get a win32exception error so that apparently the server is never created. I can create the client, I believe, because I get a NamedPipeClientStream object with no errors, and then when I try using pipe.Connect() I get the same excact win32 error. This is probably because there is no established server to connect to. My confusion is why I can create the client, but not the server? The syntax for both seems to be the same in its documentation. Here are both the examples I ran, and the reason I am using so many namespaces is because this is part of a larger chunk of code, but maybe the other namespaces are interfering with the pipe declaration. PipeServerTest.cs: using UnityEngine; using System.Collections; using System; using System.IO; using System.IO.Pipes; using System.Text; using System.Threading; using System.ComponentModel; public class PipeServerTest : MonoBehaviour { // Use this for initialization void Start () { try{ NamedPipeServerStream pipeServer = new NamedPipeServerStream("testpipe"){ print (pipeServer); } catch(Win32Exception w){ print(w.Message); print(w.ErrorCode.ToString()); print(w.NativeErrorCode.ToString()); print(w.StackTrace); print(w.Source); Exception e=w.GetBaseException(); print(e.Message); } } } PipeClientTest.cs: using UnityEngine; using System.Collections; using System; using System.IO; using System.IO.Pipes; using System.Text; using System.Security.Principal; using System.Diagnostics; using System.Threading; using System.ComponentModel; public class PipeClientTest : MonoBehaviour { // Use this for initialization void Start(){ NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "testpipe", PipeDirection.InOut); print (pipeClient); try{ pipeClient.Connect(); } catch(Win32Exception w){ print(w.Message); print(w.ErrorCode.ToString()); print(w.NativeErrorCode.ToString()); print(w.StackTrace); print(w.Source); Exception e=w.GetBaseException(); print(e.Message); } } } I'd also like to note that I'm not sure if this should go in a Start() function. When I use Main() I get no outputs... or maybe that's intended. [Reference to named Pipes][1] [1]: http://msdn.microsoft.com/en-us/library/bb546085.aspx

changing material color through C# script

$
0
0
Hi, The question is pretty clear. I thought it was just `renderer.material.color` But somehow the color doesn't change. Here is what I've got: I started with a puzzle, which contains several pieces (or in this case pipes). The start function of this puzzle is: // Use this for initialization void Start() { blocks = new GameObject[Size, Size, Size]; for (int x = -Size / 2; x < Size / 2; ++x) { for (int y = -Size / 2; y < Size / 2; ++y) { for (int z = -Size / 2; z < Size / 2; ++z) { GameObject o = (GameObject)Instantiate(Block, new Vector3(x, y, z), Quaternion.identity); Pipe p = (Pipe)o.GetComponent(typeof(Pipe)); p.PipeModel = PipeTypes[Random.Range(0, PipeTypes.Count)]; p.pipeColor = PipeColors[Random.Range(0, PipeColors.Count)]; o.transform.parent = this.gameObject.transform; blocks[x + (Size/2), y + (Size/2), z + (Size/2)] = o; } } } } The pipe class looks like this: using UnityEngine; using System.Collections; using System.Collections.Generic; public class Pipe : MonoBehaviour { private PipeState state; private GameObject instance; private Color pipeColorHighlighted; public PipeState State { get { return state; } set { state = value; setStyle(); } } private GameObject _pipeModel; public GameObject PipeModel { get { return _pipeModel; } set { _pipeModel = value; instance = (GameObject)Instantiate(_pipeModel); instance.transform.parent = this.transform.parent; instance.transform.position = this.transform.position; } } public Color blockColor = new Color(0.2F, 0.3F, 0.4F, 0.0F); public Color pipeColor; // Use this for initialization void Start () { pipeColorHighlighted = Color.red; // default test color State = PipeState.Default; } // Update is called once per frame void Update () { // respond to clicking etc... } private void setStyle() { if (state == PipeState.Highlighted) { print(pipeColorHighlighted); instance.renderer.material.color = pipeColorHighlighted; } else { instance.renderer.material.color = pipeColor; } //instance.renderer.material.color = (state == PipeState.Highlighted) ? pipeColorHighlighted : pipeColor; } } public enum PipeState { Default, Highlighted, Hovered, Selected } So far everything looks right. The pipes all get their correct color. But than, when I want several pipes to be hightlighted, I use this function: private void setHighlighted() { for (int i = 0; i < puzzle.Size; ++i) for (int j = 0; j < puzzle.Size; ++j) for (int k = 0; k < puzzle.Size; ++k) puzzle.getBlock(i, j, index).State = k == index ? PipeState.Highlighted : PipeState.Default; } But somehow this doesn't change anything. The colors just stay the same. I gues the problem is somewhere in the instantiation of the pipe objects. But I can't really find it. Thanks for the help

Creating piping model at runtime

$
0
0
Hello, guys! I'm rather new to Unity and I'm completely new to 3d-modeling, since I have web programming background. So I would be glad to get some advice from more experienced developers. As a programmer I'm creating an application now (С#+Unity3D) for modeling piping for transporting gas between the cities. The piping must be created and visualized at runtime. The route is calculated at runtime depending on the user's input. I wish to achieve the smooth look of my piping, taking into accout the terrain is not flat (based on real geospatioal data) and the piping length and some other parameters (diameter) are chosen by the user. I'm not sure my approach is going to work, but that's the only thing I have come up with by now. So, as I think, I have to create a prefab - a piping section - and instantiate it at runtime as many times as I need and then place these copies along the route and position them right. I haven't succeeded in my approach however. I just feel the lack of tools (or knowledge) that would help me with uniting the sections and positioning them at runtime smoothly. I tried creating a flexible section in Blender and export it into Unity (see https://www.youtube.com/watch?v=IrXAPC-PLLA) but can't export it so that I can bend it by using the key points(anyway, this is another issue). So my questions are: - is there any way to achieve the smooth look of the sections connections (so that it looks like a whole, seamless)? - Is there a conceptually better approach to solve my problem? Maybe I'm not aware of some Unity's features that make the solution easier/faster/better in terms of performance Thank you a lot for answering! I would be glad to hear any ideas you have on this topic

how to implement flowing of water

$
0
0
I'm trying to make 2D pipegame, (like pipe dream, pipe mania) I finished most of the work. but I can't find way to implement visualizing waterflow through pipe. My first thought was doing it by using masking. But is doesnt seem to work with some backgrounds. is there any other way to implement visualizing waterflow through piep?

Extruding tube animation possible in Unity?

$
0
0
I want to create and play an animation either in Unity or from Maya to Unity that has a tube's end snaking through the scene (like a more fluid Windows 98 pipe screensaver). I know how to accomplish this in Maya through a cv curve, but I don't know how to have it work in Unity. Any ideas?

Named pipe not working in release buid

$
0
0
I have a client pipe packed in a dll, that i reference in a controller created in Unity. When I run my project from Unity it self, there is no problem creating the pipe connection. But when I build the project and runs it stand alone, no connection is established. I am really lost to what is happening and what I am missing, can someone help me here?

Consume WCF Service

$
0
0
Hi all, I am completely new to Unity and this is my first post. My question is related to IPC; more precisely: I would like to use a WCF Service (via Named Pipe) in my Unity application. Thus, I copied the file *System.ServiceModel.dll* from *Editor/Data/Mono/lib/mono/2.0* to a newly created directory named *Plugins* in my Assets directory. Then, I included the following two Namespaces: using System.ServiceModel; using System.ServiceModel.Channels; And, with the following commands, I want to create a proxy of type NamedPipe: ChannelFactory pipeFactory = new ChannelFactory(new NetNamedPipeBinding(),new EndpointAddress("net.pipe://localhost/PipeReverse")); ClassName pipeProxy = pipeFactory.CreateChannel(); After I run my project in Unity, I get the following error: > InvalidOperationException: Channel type IDuplexSessionChannel is not supported. System.ServiceModel.Channels.NamedPipeChannelFactory1[System.ServiceModel.Channels.IDuplexSessionChannel].OnCreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) System.ServiceModel.Channels.ChannelFactoryBase1[System.ServiceModel.Channels.IDuplexSessionChannel].CreateChannel (System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) System.ServiceModel.ClientRuntimeChannel..ctor (System.ServiceModel.Dispatcher.ClientRuntime runtime, System.ServiceModel.Description.ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, System.ServiceModel.Channels.MessageVersion messageVersion, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) System.ServiceModel.ClientRuntimeChannel..ctor (System.ServiceModel.Description.ServiceEndpoint endpoint, System.ServiceModel.ChannelFactory channelFactory, System.ServiceModel.EndpointAddress remoteAddress, System.Uri via) __clientproxy_ClassName..ctor (System.ServiceModel.Description.ServiceEndpoint , System.ServiceModel.ChannelFactory , System.ServiceModel.EndpointAddress , System.Uri ) System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519) System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528) System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:338) System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:268) System.Activator.CreateInstance (System.Type type, System.Object[] args) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:263) System.ServiceModel.ChannelFactory1[ClassName].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) System.ServiceModel.ChannelFactory1[ClassName].CreateChannel (System.ServiceModel.EndpointAddress address) System.ServiceModel.ChannelFactory`1[ClassName].CreateChannel () IDL_vehicle.Start () (at Assets/Scripts/IDL_vehicle.cs:30)

Windows build for game using named pipes hangs on Stream.BeginRead

$
0
0
I have a standalone simple game that uses named pipes to communicate with a Windows forms application. The Unity game is built with .NET 2.0 (not 2.0 subset) and the Windows application is built on the .NET 4.0 Client Profile. My problem is that, whenever I launch the Windows forms app ("the server") and the Unity game ("the client"), if I close the client, it becomes non-responsive. It closes only after I close the server window. Below I post the simplified code for both the server and client. Any help on this issue would be much appreciated; also I would like to know if anyone can replicate this behaviour. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.IO; using System.IO.Pipes; using System.Runtime.InteropServices; namespace TestServer { public class Server { private const int BUFFER_SIZE = 1024; private NamedPipeServerStream PipelineStream = null; public Server() { OpenPipe(); while (true) { if (PipelineStream != null && PipelineStream.IsConnected) { Thread.Sleep(1000); } } ClosePipe(); } private void OpenPipe() { PipelineStream = new NamedPipeServerStream("Pipeline", PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, BUFFER_SIZE, BUFFER_SIZE); PipelineStream.WaitForConnection(); } private void ClosePipe() { if (PipelineStream != null) { PipelineStream.Flush(); PipelineStream.Close(); PipelineStream.Dispose(); PipelineStream = null; } } } } using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.IO.Pipes; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Text; public class Client : MonoBehaviour { private NamedPipeClientStream PipelineStream = null; private void Start() { OpenPipe(); ReadAsync(); } private void OnDestroy() { ClosePipe(); } private void OpenPipe() { PipelineStream = new NamedPipeClientStream(".", "Pipeline", PipeDirection.In, PipeOptions.Asynchronous); PipelineStream.Connect(); } private void ClosePipe() { if (PipelineStream != null) { PipelineStream.Close(); PipelineStream.Dispose(); PipelineStream = null; } } private void ReadAsync() { if (PipelineStream != null && PipelineStream.IsConnected) { byte[] buffer = new byte[1]; PipelineStream.BeginRead(buffer, 0, 1, ReadAsyncCallback, null); } } private void ReadAsyncCallback(IAsyncResult result) { int amountRead = PipelineStream.EndRead(result); if (amountRead > 0) ReadAsync(); } }

How to move a ship inside a pipeline

$
0
0
Hi All! I'm developing a pipeline racing game in which a ship moves inside a pipe. I need that the movement is smooth and the ship os always touching the internal surface of the pipeline, and it rotates by side along the pipe surface. Now i have a scene setted in this way: 1) The Pipelin (flipped direction) width meshcollider and rigidbody kinematik without gravity with high mass 2) The Player, that is a empty GO with sphere collider that has the diameter of 1 - the diameter of the pipe, and a rigidbody non kinematik and non gravity with the following script 3) Childs of the Player, there are the ship and the camera. The ship is positioned at the bottom of the spehere near the pipe surface, makeing the sensation of touching it All that makes life with this C# script that controls the Player (the Sphere with attached the ship): using UnityEngine; using System.Collections; public class PipeSphereMotion : MonoBehaviour { public float speed; public float torqueSpeed; private Vector3 dir; void FixedUpdate () { RaycastHit leftHit; RaycastHit topHit; RaycastHit rightHit; RaycastHit downHit; Physics.Raycast (transform.position, Vector3.left, out leftHit); Physics.Raycast (transform.position, Vector3.up, out topHit); Physics.Raycast (transform.position, Vector3.right, out rightHit); Physics.Raycast (transform.position, Vector3.down, out downHit); dir = (Vector3.Cross (leftHit.normal, topHit.normal) + Vector3.Cross (rightHit.normal, downHit.normal)).normalized; if (Input.GetAxis ("Vertical") > 0) rigidbody.AddRelativeForce (-dir * speed); if (Input.GetAxis ("Vertical") < 0) rigidbody.AddRelativeForce (dir * speed); if (Input.GetAxis ("Horizontal") > 0) rigidbody.AddRelativeTorque (-dir * torqueSpeed); if (Input.GetAxis ("Horizontal") < 0) rigidbody.AddRelativeTorque (dir * torqueSpeed); } } Now, in the rectilinear it's all ok: the ship runs forward and strafes along the sides of the pipe, but when arrives the curve, the sphere inside the pipe rolls around... Is there a method (maybe with better raycasts, i think i do the mine wrong) to force the sphere to face always forward to the pipe irection?
Viewing all 89 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>