Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

nati1189

Member
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

1 Neutral

About nati1189

  • Rank
    Member

Profile Information

  • Gender
    Not Telling
  • Location:
    israel
  1. hello i wrote a simple connection script using socket this is my server script (Visual stuido Console Projcet) private static Socket _SERVER; private static Socket _CLIENT; private static byte[] _BUFFER; private static NetworkStream _STREAM; private static string _IPADDRESS = "127.0.0.1"; private static int _PORT = 8888; static void Main(string[] args) { try { _SERVER = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _SERVER.Bind(new IPEndPoint(IPAddress.Parse(_IPADDRESS), _PORT)); _SERVER.Listen(500); Console.WriteLine("[server] Server started succesfully"); } catch { Console.WriteLine("[server] Failed to start server"); } while(true) { Console.ReadLine(); } } and this is my client script (Unity) public Socket _CLIENT; public NetworkStream _STREAM; public string _IPADDRESS; public int _PORT; void Start() { bool clientStarted = StartClient(); if (clientStarted) { Debug.Log("[Client] Client ready"); } else { Debug.Log("[Client] Failed to start client"); } Connect(); } public bool StartClient() { try { _CLIENT = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); } catch { return false; } return true; } public void Connect() { try { _CLIENT.Connect(IPAddress.Parse(_IPADDRESS), _PORT); _STREAM = new NetworkStream(_CLIENT); Debug.Log("[Client] Connected to server"); } catch { Debug.Log("[Client] Failed to connect to server"); } } all seem to work perefectly fine. what should i do next? i want to spawn player and sync his position over the network thanks
  2. thanks i will keep searching for tutorials on youtube its just i tried few tutorials and most of them didnt work so but i will keep searching thanks
  3. thanks for the help its a very good tutorial im gonna try it! i just wonder if u know any C# tutorials? thanks
  4. can someone give a good tutorial about how to write socket for game? i want to server to be a console project and to learn how to send and recive things such as players positions and more someone know a good tutorial? thanks anyway
  5. nati1189

    help with gui

    this is what i want to do: i right click on item (button) and 2 buttons show (Use and Drop) where i pressed my buttons in my inventory script are in a for loop
  6. nati1189

    help with gui

    thanks for the answer i need it for my inventory and there are alot of buttons in the inventory. im using for loop and its hard to set the position of the buttons i wonder if theres a easier way to do this thanks anyway
  7. nati1189

    help with gui

    hello i want to do when i click GUI.button it gives me options like when you right click a folder. can u help me start thanks
  8. i managed to do it by myself thanks for everything
  9. this is my OnGUI function now: void OnGUI() { render_h = 0; slot.y = 0; for (int i = 0; i < playerInventory.Capacity; i++) { for (; render_h < HEIGHT; render_h++) { render_w = 0; for (; render_w < WIDTH; render_w++) { if (playerInventory[i] != null) { if (GUI.Button(slot, playerInventory[i].itemIcon)) { if (cursorTexture == null) { itemDraggingNowSlot = i; itemDraggingNowClass = playerInventory[i]; cursorTexture = playerInventory[i].itemIcon; Cursor.SetCursor(cursorTexture, hotSpot, cursorMode); } else { playerInventory[itemDraggingNowSlot] = playerInventory[i]; playerInventory[i] = itemDraggingNowClass; itemDraggingNowSlot = -1; itemDraggingNowClass = null; cursorTexture = null; Cursor.SetCursor(null, hotSpot, cursorMode); } } } else { if (GUI.Button(slot, emptySlot)) { if (cursorTexture == null) { itemDraggingNowSlot = i; itemDraggingNowClass = playerInventory[i]; cursorTexture = null; Cursor.SetCursor(cursorTexture, hotSpot, cursorMode); } else { playerInventory[itemDraggingNowSlot] = playerInventory[i]; playerInventory[i] = itemDraggingNowClass; itemDraggingNowSlot = -1; itemDraggingNowClass = null; cursorTexture = null; Cursor.SetCursor(null, hotSpot, cursorMode); } } } slot.x += slot.width; } slot.x = 0; slot.y += slot.height; } } } in gives me a strange result it look like there are alot of buttons on top of each other can you help me solve this? should i upload image of my result? thanks anyway
  10. hey thanks for the answer it doesnt work for me i forgot to say im using GUI.window and i wonder if u can help me do this while using gui window thanks anyway
  11. public List<ItemClass> playerInventory = new List<ItemClass>(); void DrawInventory(int windowID) { for (int i = 0; i < playerInventory.Count; i++) { if (GUILayout.Button(playerInventory.itemIcon, GUILayout.Width(100), GUILayout.Height(100))) { Debug.log(playerInventory.itemName + " Used"); } } } this is my inventory window function what i want to do is the first 6 items will be in one line the the next 6 items in a difrent line and so on... i have 2 questions: 1.can i use the new 4.6 UI system to do this? 2.how can i do this using GUILayout.BeginHorizintal("");?
  12. should i post scripts?
  13. I know unity networking but im using TCPListenter and TCPClient for my project and when im unity Netowrk.instantiate im getting an error saying unity cant instantiate the object becuse im not connected to server . My server program is a console application i created using Visual Stuido
  14. hello i made a simple netowkr code using socket now i want to spawn the player how can i use Network.instantiate with socket? is there a difrent way of doing it? thanks
  15. nati1189

    unity NAT problem

    unity NAT target 37 not connected to NAT facilitator this is the error im getting while trying to connnect a server can someone help me solve it? thanks
×
×
  • Create New...