Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

447 Neutral


About NDraskovic

  • Rank

Personal Information

  • Interests


  • Twitter

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I went and made my own parser, it works fine so far, so I'll be using that, but thanks for the answers, it's going to come in handy later.
  2. Yeah, the data is just an array. I made my own simple parser, fortunatelly the data is not too complicated, so I'm just going trough the string and pulling out entries one by one and then using JSON to convert them to the objects I need, so let's say that this part is solved (it's not pretty, but it works). I managed to bypass the WebRequest problem by using WWW class instead of WebRequest, and that class works perfectly. Thanks to everyone for your help.
  3. I can't change the data on the server side, so I've added the "{\"results\": to the text I get (and of course the following closing bracket). Now I don't get any errors, but the results array is null.
  4. Yeah I changed it so that it looks like an object, but didn't help. I pulled just one entry from the array and hardcoded it into the function, and then it converts the object properly, so in worst case scenario, I'll parse the string myself and convert them one by one. The other part of the question is still puzzling me.
  5. Tried it but now I get ArgumentException: JSON parse error: Missing a name for object member.
  6. Hey guys, I have a really weird problem. I'm trying to get some data from a REST service. I'm using the following code: private void GetTheScores() { UnityWebRequest GetCommand = UnityWebRequest.Get(url); UnityWebRequestAsyncOperation operation = GetCommand.SendWebRequest(); if (!operation.webRequest.isNetworkError) { ResultsContainer rez = JsonUtility.FromJson<ResultsContainer>(operation.webRequest.downloadHandler.text); Debug.Log("Text: " + operation.webRequest.downloadHandler.text); } } The problem is that when I'm in Unity's editor, the request doesn't return anything (operation.webRequest.downloadHandler.text is empty, the Debug.Log command just prints "Text: "), but when I enter the debug mode and insert a breakpoint on that line, then it returns the text properly. Does anyone have an idea why is this happening? The real problem I'm trying to solve is that when I receive the text, I can't get the data from the JSON. The markup is really simple: [{"id":1,"name":"Player1"},{"id":2,"name":"Player2"}] and I have an object that should accept that data: [System.Serializable] public class ResultScript { public int id; public string name; } There is also a class that should accept the array of these objects (which the JSON is returning): [System.Serializable] public class ResultsContainer { public ResultScript[] results; } But when I run the code (in the debug mode, to get any result) I get an error: ArgumentException: JSON must represent an object type. I've googled it but none of the proposed solutions work for me. Also (regardless if I'm in the debug mode or not) when I try to do some string operations like removing or adding characters to the GET result, the functions return an empty string as a result Can you help me with any of these problems? Thank you
  7. Hey guys, Like the title says, I'm trying to find out if it's possible to automatically set which scenes will be built for different platforms. For instance, I have scenes that I want to include when building for PC, but exclude them for mobile platforms. Is it possible to do this automatically (by some settings file, or by coding some editor extension), or do I have to manually (de)select them each time I switch platforms? Google just keeps sending me to the documentation sites about the regular publishing, but I can't find information about this problem. Thanks in advance
  8. Yeah that is the approach I'm using at the moment, I was just wandering if there is a "smarter" way. Thanks anyway.
  9. I tried with InControl, but couldn't find a way, so I'm asking for any suggestion, not only InControl, but built in Unity or some third party plug in.
  10. Hey guys, I'm working on a local multiplayer game that uses multiple controllers (joysticks) on the same computer/console. I downloaded the InControl asset that should help with the input, but I can't find a way to detect which of the connected controllers was used to perform some action (i.e. on which controller was the button pressed). The application detects the actions properly, but it doesn't make any difference if joystick 1 or 2 "sent" the action. The only way I could accomplish this is to define specific axis (or more precisely, 20 axes for each controller) in Unity's input manager, but that seems too crude, and very unpractical to use within code. Is there another way to know which joystick performed the given action? Thanks
  11. Thanks, I'll try that. Now that I did some more research, I'm not 100% sure if the devices are actually on the same network, which might be the source of the problem. Thanks for the suggestion, It will be useful later on.
  12. Hey guys, As the title says, I'm trying to control a desktop game by using my mobile phone as a controller. I created two scenes, one that acts as a server, other as a client. Server has this code: void Start () { Test = "Nothing yet happened"; NetworkServer.Listen(25000); NetworkServer.RegisterHandler(888, ServerReceiveMessage); } private void ServerReceiveMessage(NetworkMessage message) { StringMessage msg = new StringMessage(); msg.value = message.ReadMessage<StringMessage>().value; if (!String.IsNullOrEmpty(msg.value)) { Test = "Message received"; string[] deltas = msg.value.Split('|'); Horizontal = Convert.ToSingle(deltas[0]); Vertical = Convert.ToSingle(deltas[1]); TestScript.MoveForward(Vertical); TestScript.RotateAroundY(Horizontal); } else { Test = "Nothing received"; } } And client this: private void Connect() { client.Connect(IPAddress, 25000); } void Start () { client = new NetworkClient(); Connect(); } void Update () { #if UNITY_ANDROID MobileTouches = Input.touches; if (MobileTouches.Length > 0) { for (int i = 0; i < MobileTouches.Length; i++) { if (MobileTouches[i].phase == TouchPhase.Moved) { Horizontal = MobileTouches[i].deltaPosition.x; Vertical = MobileTouches[i].deltaPosition.y; }else if(MobileTouches[i].phase == TouchPhase.Stationary) { Connect(); } } } #elif UNITY_EDITOR Horizontal = Input.GetAxis("Horizontal"); Vertical = Input.GetAxis("Vertical"); #endif thumb.Translate(Vector3.up * Vertical * Time.deltaTime); thumb.Translate(Vector3.right * Horizontal * Time.deltaTime); SendControllerInfo(); } static public void SendControllerInfo() { if (client.isConnected) { StringMessage msg = new StringMessage(); msg.value = Horizontal + "|" + Vertical; client.Send(888, msg); } } Ip address is hard coded, I just replaced it with the "IpAddress" variable. The code itself builds fine, and when I try to run in on a desktop computer, it works as expected (just a simple movement of an object on the server screen). However when I try to publish the client scene to a mobile device (Android), it doesn't connect to the server. They are both connected to the same network. Can anyone tell me what the problem might be? Thanks
  13. I'm using AddTorque to turn the car, and that function does not have a positional option (torque is applied around the provided axis). I'll try switching to AddForceAtPosition, and see what happens. This part is a bit tricky to explain - we would like the driving itself to be as realistic as possible (obviously, we are making a game, not a simulation, so some concessions will be made to speed the development up), however our vehicles have the ability to "fly" (not like airplanes, but they need unrealistic maneuvering capabilities when airborne), so the behavior of the vehicle differs when grounded and airborne. We have mechanism in place that determine if the car is grounded or not, but they are not perfect (for instance how to differentiate between the flight we want to control, and a simple bump on the road), so that causes some problems. I've tried switching from one "main" rigidbody to main+4 wheel rigidbodies, but it causes the vehicle to go crazy on every little bump (it gets too shaky, and very hard to stabilize, even with anti roll code implemented). The most obvious problem that I want to solve with this is the following scenario: - if the vehicle is close to the wall or any other type of fixed obstacle and I try to turn to the opposite side, the back of the car moves towards the wall and causes a collision that pushes the vehicle back to the wall. In reality, the front wheels would pull the car, without the back of the car going the opposite way Do you have any suggestion that might help me with that problem? Thanks for your input
  14. Hey guys, We are working on a project that revolves around driving different types of vehicles. We have already created a basic driving mechanism that works very well, but one of the problems we are having is that the vehicles are obviously rotating around their middle (or more precisely, around their center of mass) which doesn't look too realistic. Moving the center of mass towards the front of the vehicle gave a bit better result, but it makes the vehicles more unstable on frontal collisions and bouncing when encountering terrain unevenness. Our goal is to have the front wheels turn first and "pull" the rest of the car behind them. We are not using wheel colliders, rather one rigidbody (attached to the body of the car) to which we add forces and torque. The code itself is pretty simple, it calculates the turn vector with regards to car mass, user input and some other parameters that we added to each vehicle to differentiate them, and then add torque to the car rigidbody with regards to that vector. My question is, have you encountered this problem, and what would be your suggestion on solving it? Thanks
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!