Questions in topic: "communication" The latest questions for the topic "communication" Access the content of another script So... I am trying to go through some old unity tutorials, trying to make sort of a quiz game... The thing is ... they do it by getting scripts to communicate with one another. I tried going back, tried to see if the most basic code possible can communicate with each other. using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptA : MonoBehaviour { public ScriptB other; void Update() { other.DoSomething(); } } ------------------ using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptB : MonoBehaviour { public void DoSomething() { Debug.Log("Hi there"); } } Well... The thing is... It did not work. I created 2 empty objects in an empty 2D scene, attached ScriptA to one, attached ScriptB to the other, dragged the empty object with ScriptB into the field of ScriptA ... And it displayed nothing. I am not sure what I did wrong. Please help. nullreferenceexception scripting beginner communication basics Mon, 13 May 2019 15:44:33 GMT rrtkd Combining python and Unity 3D To make this short and simple. I have TCP socket in my unity project that receives communication from a python script (in a separate python app, using Spyder right now). Is it possible to somehow combine these two programs into one concise app? I am pretty sure Unity does not have this capability built in (if it does please let me know). Is there a work around? Am I able to create like an umbrella app using different software to start up both programs. app communication bundle tcp python Mon, 01 Apr 2019 17:56:46 GMT cchpackers1 Script doesn't call method from other script I have a problem, I want to make that when the player enters the trigger box of an enemy, it activates the attack animation of that enemy, and in a frame in the middle of the animation, the method "OnExplode" is executed, which is already defined in its own script. However, I have achieved that when the player approaches the animation plays, but the method of the other script is not executed. I have added an event in the animation (in an intermediate frame) that executes the method "Attack()". Does anyone know what may be wrong? It's from a online course and I downloaded the teacher's files, but it has the code exactly like me and the same thing happens. private void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.tag == "Player") { if (readyToAttack) { var explode = collision.GetComponent<Explode>() as Explode; explode.OnExplode(); } else { GetComponent<Animator>().SetInteger("AnimState", 1); } } } private void OnTriggerExit2D(Collider2D collision) { readyToAttack = false; GetComponent<Animator>().SetInteger("AnimState", 0); } void Attack() { readyToAttack = true; } 2d 2d-platformer not working method communication Thu, 31 Jan 2019 19:49:56 GMT Mufufado Control game via website Just wanted to drop this quick question: <br><br> Is it possible to control a game via website. Meaning, can I add a button to the website that every visitor is able to press. And this button, for example, simply adds force to a cube to launch it in the air. The game is not, necessarily, run in WebGL and on the same website, but on a different machine. <br><br> If you could provide terms, topics or similar that I can look at to achieve this goal, that would be great. I found some resources but on different topics, that wouldn't apply to this concept. networking web communication Sun, 13 Jan 2019 21:44:27 GMT Mukaujoka Cant login through asset store tools Hi, i am using a VPN to connect to Unity, I am already signed in through asset store, but i cant login through asset store tools. - tried using my email instead of username > not successful. - tried adding/removing a Proxy environment variable > not successful . ![alt text][1] [1]: /storage/temp/126519-capture.png asset store login communication failure account Mon, 22 Oct 2018 18:03:08 GMT afsoft Communitate with other Programs in Realtime. ( / websocket?) I wondering how to communicate between Unity and another application in realtime. I tried / websocket. But I don't found a correct working library (asset). For example [Socket.IO for Unity][1]. This library works until events are emitted. It connects to my websocket (socket io forced to only use websocket), but after emitting an event from server to client, the client only reconnects. (loop / on every event). Another [Socket.IO][2] Asset (on [github][3] for free) has conflicts with the unity engine scripts. (Errors like ... is defined multiple times.) <br> **Conclusion**: There is no correct working socket io / websocket library. I looking for alternatives. Any idea or hint will help. Thanks for advice. <br> Btw. `` is more a pseudo websocket library. Because in most of cases it runs on polling / ajax. You can force to use websocket by `transports` option to `['websocket']`. But the most examples does not work. In my case a simple websocket server with does not really works. The server recognized a connection but fails on events. (without errors. the events just don't work). At all this is very disappointing. But anyway. The lib for Unity has an example with socket io forced with websocket. But there I have the loop connection problem on event emit. [1]: [2]: [3]: realtime socket communication Mon, 24 Sep 2018 16:19:39 GMT Domvel Unity-Arduino wifi Communication Hi! Im looking for some simple example code that allows sending and recieving a string between my Arduino-Mega and Unity on my PC via my home Wifi. Im very unexperienced when it comes to non-serial communication and would appreciate any information on how to choose the port, which IP to use and if there must be a server-client communication or if it can just be two way direct. Thank you in advance for your help.,Dear Forum, Im looking for a simple example code which allows for sending and recieving a string between unity3d and arduino through my home wifi. unity 5 communication arduino Fri, 21 Sep 2018 12:04:18 GMT taquizan Arduino Unity bluetooth Hello guys, I'am not sure where to ask this on unity or arduino... So I want to send a character from unity to arduino and also receive a float from arduino to unity... I searched the asset store and all of the assets are paid and I cant really buy online... So is there a way to communicate with arduino HC-05 ? free bluetooth communication arduino Tue, 26 Jun 2018 16:10:21 GMT HarD-izzeR What is needed to access slack ? Hi, I am new to Unity. I just checked out, there are at least 2 slack workspaces `,`. But in order to join I need to have some special email addresses (ending on How to get these?![alt text][1] [1]: /storage/temp/118623-capture.jpg In case of it reads `If you have an or email address, you can create an account.` How to get google email address, but most important how to join slack for these? communication Sat, 09 Jun 2018 22:57:52 GMT Julijana How I create game for pc and get inventory for an app on my cell phone? Hi everyone, I was trying to make a rpg game where you play it on the pc, but I can get inventory for an app on my cell phone, how can I make this communication? Sorry for my English, english is not my native language. android interface interaction communication rpg-game Sat, 12 May 2018 14:37:07 GMT luisfelipecaruzo send string to serial port on android send string to serial port on android: I have tried using "" it failed because doesn't work on android devices because of mono, next step was to create a jar plugin to use in unity but it needs a permission that I couldn't fix. I was wondering if there is any asset on asset store or any where else or maybe some have found the way. android communication usb serialport Tue, 08 May 2018 14:52:59 GMT muheydari Arduino Communication Hi. I have a huge problem that I do not know how to solve it. Broadly speaking I am controlling an exoskeleton and I need Arduino to send Unity (via serial) the data of the motor encoders. Later, I calculate several things and in the end I return certain values back to Arduino. The corresponding codes are: using UnityEngine; using System.Collections; using System.IO.Ports; using System.IO; using System; public class prueba_com2vias : MonoBehaviour { bool firstContact=false; SerialPort st = new SerialPort("COM7", 9600); string value; string initial; string data; string[] vec3; // Use this for initialization void Start () { st.Open (); //st.ReadTimeout = 100; } // Update is called once per frame void Update () { if (st.IsOpen) { try{ //value = st.ReadLine(); serialEvent(st); } catch(System.Exception){ throw; } } } void serialEvent(SerialPort stream){ //stream.ReadTimeout = 10; value = stream.ReadLine(); if (value != null) { initial = value.Substring (0, 1); if (firstContact == false) { if (initial.Equals ("S")) { stream.BaseStream.Flush (); firstContact = true; stream.Write ("S"); stream.BaseStream.Flush (); } } else { try{ if(initial.Equals("1")){ data = value.Substring(1); vec3=data.Split('/'); if (vec3.Length==6){ Debug.Log (data); } stream.Write("@16901"); } } catch(System.Exception){ } } } } } And. #define ENCODER_OPTIMIZE_INTERRUPTS // int pot1, pot2,pot3,pot4,pot5,pot6; String inString; String zp_3d; int sel = 0; void setup() { Serial.begin(9600); pinMode(13,OUTPUT); noInterrupts(); // TCCR1A = 0; TCCR1B = 0; TCNT1 = 55536; TCCR1B |= (1 << CS11); TIMSK1 |= (1 << TOIE1); interrupts(); // establishcontact();// } ISR(TIMER1_OVF_vect){ TCNT1 = 55536; leer_pot(); } void loop() { if (Serial.available() > 0) { while(Serial.available()>0){ inString = Serial.readStringUntil('\n'); data_rec(inString); } Serial.print("1");Serial.print(pot1); Serial.print("/"); Serial.print(pot2); Serial.print("/"); Serial.print(pot3); Serial.print("/"); Serial.print(pot4); Serial.print("/"); Serial.print(pot5);Serial.print("/"); Serial.println(pot6); } } //////////////////////////////////////////////////////////////// void leer_pot(){ pot1=analogRead(A0); pot2=analogRead(A1); pot3=analogRead(A2); pot4=analogRead(A3); pot5=analogRead(A4); pot6=analogRead(A5); } //////////////////////////////////////////////////////////// void data_rec(String inString){ String mark = inString.substring(0,1); String command = inString.substring(1,2); String data = inString.substring(2); if(mark == "@"){ if(command == "1"){ sel = data.substring(0,1).toInt(); zp_3d = data.substring(1,3); } if(sel==6) { analogWrite(13,255); } } } void establishcontact() { while (Serial.available() <= 0) { Serial.println("S"); delay(300); } } But, when I try to run the program, Unity makes it extremely slow (something problematic because of my goal). On the other hand, when I add the line st.ReadTimeout = 100; I get the following error (regardless of the written value): TimeoutException: The operation has timed-out. System.IO.Ports.WinSerialStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) System.IO.Ports.SerialPort.read_byte () System.IO.Ports.SerialPort.ReadTo (System.String value) System.IO.Ports.SerialPort.ReadLine () (wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort:ReadLine () prueba_com2vias.serialEvent (System.IO.Ports.SerialPort stream) (at Assets/prueba_com2vias.cs:37) prueba_com2vias.Update () (at Assets/prueba_com2vias.cs:25) Could someone help me to guide me in what I do wrong? Thanks for the help. communication Tue, 17 Apr 2018 21:48:12 GMT ljhs Smartphone communication I was wondering about communication between two android smartphones. I know probably the best and the most user friendly solution is to have remote server and communicate through it but what I want is a simple and independent smartphone-to-smartphone communication. Do you reccomend any simple solution to achieve it? android server communication Wed, 11 Apr 2018 20:16:22 GMT Ponczix Sharing custom made game levels with other users during gameplay. I am building a game where users can create their own levels from sandbox and share it with other users for playing. Something similar to this scenario, Say game name is Image Puzzler. User A: Creates a puzzle using her own photo and wants to share it with User B. She wants User B to solve the puzzle and view the final photo. User B: Loves this concept of creating own photo puzzle game. She decides to share her own puzzle photo with all the users of Image Puzzler game. I am pretty sure I would need servers to identify users and share data, or is there any straight forward way to achieve this? I am also clueless about how the puzzle data from User A be passed to User B. Could someone help me with right pointers. Thank you! serialization data communication sharing customize Wed, 11 Apr 2018 12:19:28 GMT agilanbtdw How can I receive UDP messages or similar in WebGL? Hi. I have a java app that sends UDP messages, and I need to build a Unity WebGL app that receive those messages and do stuff. I read that WebGL doesn't support UDP communication because of security reasons. Okay, I thought on 2 possibilities: 1- Build another java app that sends TCP messages and try to receive them on unity. 2- Build another java app that communicates with unity using WebSockets. I tried both of them, but didn't get it. I'm a bit lost. Is what I want even possible? webgl socket communication udp tcp Thu, 18 Jan 2018 07:07:29 GMT TheSherN How can I receive UDP messages or similar in WebGL? Hi. I have a java app that sends UDP messages, and I need to build a Unity WebGL app that receive those messages and do stuff. I read that WebGL doesn't support UDP communication because of security reasons. Okay, I thought on 2 possibilities: 1- Build another java app that sends TCP messages and try to receive them on unity. 2- Build another java app that communicates with unity using WebSockets. I tried both of them, but didn't get it. I'm a bit lost. Is what I want even possible? webgl socket communication udp tcp Tue, 16 Jan 2018 11:58:43 GMT TheSherN How one can exactly send the rendered scene from PC to mobile I am running a single-player VR game on my phone perfectly. How I can remotely render the same game scenes on unity running on PC and PC will send me the requested rendered frame and then phone will display it. I have the TCPclient on my phone for requesting that. But how can I send the rendered frames from PC to mobile? I am also looking for the normal nonVR games. Is it possible strong PC does the rendering and sends to mobile upon request. scene render communication Thu, 04 Jan 2018 21:29:16 GMT spaul13 How to use protobuf in Unity for communication ? Case is: Unity Exe and an Exe has to communicate and exchange data. (Optional/Exact case:The other Exe communicates through protobuf, Unity has to recieve and act.) communication Wed, 06 Dec 2017 14:13:33 GMT Krish-Vikram Using External NFC Read with Unity Hi, Has anyone had any success with using an External NFC reader in Unity. All the examples i can find are using Android NFC, however i'm doing a project on PC so i'm unable to use that obviously. If anyone can point me in the right direction or has a solution that can help, it would be most appreciative. communication read external Fri, 13 Oct 2017 01:50:39 GMT JacobFlynnPrendi How Can I create VOIP for two players to communicate over voice while playing or is it even possible in unity? I want to know two things: 1. I want to create a mobile phone game where two or more players can communicate over voice at real time using voip if they prefer to. Is that possible in unity? If so any reference or link? 2. It would be better if I had an option where they can video call each other if they prefer to. Is that possible if so then please share the link Any kind of help is highly appreciated. Thanks in advance networking multiplayer communication video streaming Wed, 20 Sep 2017 07:31:16 GMT Nauzer Assets Store "Failed communication" Hi guys, i was wondering if somebody could help me with this deep problem! When i press Login in Assets Store Tools, it shows an error which is not clear if it is because of connection, wrong username, wrong password etc(but it seems its because of connections as it writes COMMUNICATION lol)! I would be appreciated if you guys help me:) Not a formal text, but regards! assets assetstore communication Sun, 20 Aug 2017 19:18:10 GMT Arminyazdian How do we use AddJavaScriptInterface of WebView in any game for iOS & Android to call a function at the Unity end from the web page end? There is a WebPage hosted in a server. This page contains several buttons in it. I am opening this webpage within Unity in Android & iOS using UniWebView plugin. When this webpage is opened within UniWebView's webview, several buttons are displayed within the page. I want, when a user clicks a button in the web page, a function will get executed at the game end at the mobile end. Moreover, I have seen a project in XCode, where UIWebView is being used. While loading the page in the webview, an object of a class is being sent with a key named "Native". The name of the class is JSInterface, which implements a JSExport type of interface. This JSInterface class implements all the functions of the JSExport interface class. When the user clicks a particular button within the web page, one of the functions in the JSInterface class gets called. This way a function at the native iOS end gets fired from within the web page. Can anyone suggest me, how we can do the same in Unity? import UIKit class ViewController: UIViewController { @IBOutlet weak var baseWebView: UIWebView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let loadRequest = ""//TEST_URL// let request = URLRequest(url: URL(string: loadRequest)!) as URLRequest baseWebView.loadRequest(request) let jsInterface = JSInterface() baseWebView.addJavascriptInterface(object: jsInterface, forKey: "Native") } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } import Foundation import JavaScriptCore import UIKit @objc protocol MyExport : JSExport { // --------- Testing index.html ----------- func check(_ message : String) func sayGreeting(_ message: String, _ name: String) func sayGreeting() func anotherSayGreeting(_ message: String, name: String) func showDialog(_ title: String, _ message : String) // ---------------------------------------- // func onLogin_voucher_ButtonClick(_ pageName: String) func onLogin_voucher_ButtonClick(_ pageName: String,_ back: String) func onClassicWebsiteClick() func onLogoutSuccess() func onSessionInvalid() } class JSInterface : NSObject, MyExport { var loginOrVoucherClicked: ((_ page: String, _ successOrBack: String) ->())? var classicWebsiteClicked: (() ->())? var logoutSuccess: (() ->())? var sessionInvalid: (() ->())? // --------- Testing index.html ----------- func check(_ message: String) { debugLog("JS Interface works!") } func sayGreeting(_ message: String, _ name: String) { debugLog("sayGreeting: \(message): \(name)") } func sayGreeting() { debugLog("sayGreeting") } func anotherSayGreeting(_ message: String, name: String) { debugLog("anotherSayGreeting: \(message): \(name)") } func showDialog(_ title: String, _ message : String) { DispatchQueue.main.async { UIAlertView(title: title, message: message, delegate: nil, cancelButtonTitle: "OK").show() } } // ---------------------------------------- // func onLogin_voucher_ButtonClick(_ pageName: String){ // if loginOrVoucherClicked != nil { // loginOrVoucherClicked!(pageName) // } // } func onLogin_voucher_ButtonClick(_ pageName: String,_ back: String) { debugLog("\(pageName)::::\(back)") if loginOrVoucherClicked != nil { loginOrVoucherClicked!(pageName, back) } } func onClassicWebsiteClick(){ if classicWebsiteClicked != nil { classicWebsiteClicked!() } } func onLogoutSuccess(){ if logoutSuccess != nil { logoutSuccess!() } } func onSessionInvalid() { if sessionInvalid != nil { sessionInvalid!() } } } unity 5 communication calling webpage webview Tue, 25 Jul 2017 06:22:33 GMT pranoyparimal unity control real world devices I am an electrical engineering student and i need to make a UI to receive data from sensors, display it and then sent user commands to a controller. I have been looking for a UI system that can do this. is unity capable of doing this. ui data communication Sat, 15 Jul 2017 05:54:53 GMT lowteck into the void I don't know. Sometimes it's like I'm typing into the void communication Thu, 06 Jul 2017 22:30:53 GMT bryansears Communication between uniwebview and GameObject I have been spending some time in communicating from uniwebview to objects within or outside the scene. I could connect from uniwebview html page to the script using " uniwebview:// " and it succesfully works. Actually I need to destroy the current object and make another object active. However the destruction works using "this.destroy()", but I'm having a hard time making the other object active. The code which I used to activate is : " var test = gameobject.find("TestObject"); test.setacive(true); " Any guidance would be appreciated for the same. Thanks activate communication webview Mon, 08 May 2017 14:29:12 GMT stanly3690 How to commuunicate scripts form default namespace? Hi, I got a problem. How to take values form script One to script Two, when the first script is in different namespace? I mean i got something just like this (let's say it is so short) first script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptOne : MonoBehaviour { public float iWantThisVariableInAnotherScript; } And I want to have an access to this variable in another script (it's ready script in Unity - FirstPersonController, so I guess all of you know that script). And it looks like: namespace UnityStandardAssets.Characters.FirstPerson { [RequireComponent(typeof (CharacterController))] [RequireComponent(typeof (AudioSource))] public class FirstPersonController : MonoBehaviour { AND HERE, HOW TO GET ACCESS TO MY public float iWantThisVariableInAnotherScript ?? } } I am sorry for my spelling mistakes, be permissive :) I'm waiting for Your responses. script. namespace communication different Mon, 01 May 2017 14:40:28 GMT Walet How to communicate between iOS and Unity3D? We have small interactive activities and a Native loader that loads all unity activities. We want an issue in communication between loader and activities. When the activity is opened from the loader it should show back button that will move us to the loader again. But when an individual activity is opened directly without a loader as an app it shouldn't show the back button. Now the problem here is we don't get to know when the activity is opened from the loader or directly. Please help use to find the proper way of offline communication. unity 5 ios playerprefs communication Fri, 28 Apr 2017 05:43:32 GMT Tejal1234 Bluetooth Description in Xcode Apple requires that if you use Bluetooth in your application you include a description in the info.plist file. I am the creator of a Bluetooth Low Energy plugin for Unity that provides an interface for Bluetooth Low Energy devices. I usually tell my customers to add the required description to their Xcode project manually and then use the Append when they build. The problem is for those customers who use Cloud Build to build for iOS. In this case there is no way to enter the required description as part of the project. Unity has added description entry for the Camera and Location services. How can I get the same functionality for Bluetooth usage? build xcode cloud communication Tue, 18 Apr 2017 19:04:41 GMT Hotshot10101 Unity don't process windows message(like a WM_KEYDOWN) when it run in background! hello! i want to send a WM_KEYDOWN windows message to Unity when it is running in background. I have already done it. But Unity did not immediately processing. Unity process that message when it get focus. I have already selected the "Run In Background" options. That's all. I don't have to find useful information on Google. I would appreciate it if you could help me. Thanks! windows communication Tue, 28 Feb 2017 08:15:41 GMT ShareMemory Data transfer PC (C++ application) -> Android smartphone (Unity3D) using WiFi Hi, I am in the phase of developing a C++ software running on a PC that will communicate with an Android application on a smartphone that runs Unity3D. I would like to use WiFi. I am familiar with Android development and I followed/implemented some Unity3D tutorials. Does anybody have experience with this? I would like to start with a simple example where I type some text from my C++ software (on my PC) and this text gets displayed on the Android smartphone within Unity3D. Am I wanting too much? Thank you in advance. android c++ communication Thu, 05 Jan 2017 10:26:07 GMT fpoiesi