Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Rigidbody custom TCP/UDP client-server collaboration

Discussion in 'Physics' started by TheProxor, Jan 8, 2019.

  1. TheProxor


    Apr 14, 2013
    Hi there. I write my own framework for TCP/UDP Client-Server app (by Net.Sockets).
    Server - it's my Console Net Core app for Linux (I rent server with Ubuntu and install dotnet - Screen 1)
    Client - it's my game on Unity (Screen 2).

    I have a few cubes in Unity. Current client cube has rigedbody for motion. Other cube postion lerped by response from Server. For current client cube motion I use:

    Code (CSharp):
    1. rigidbody.velocity = new Vector3(Input.GetAxis("Horizontal"), -gravity, Input.GetAxis("Vertical")) * speed * Time.deltaTime;
    After I send current position via UDP to Server, and Server send this position for other clients.

    What i want: if I has movement in current client and touch other cubes - they rigidbody receive velocity from me and move away from me.

    I know that I can detect touch rigidbody of first cube and collider of second, and send TCP command "AddForce" and make "Rigidbody.AddForce(recieved vector)", but there may be an easier way.

    For example, I remember was a Network Rigidbody... But this work only in Unity environment.