Search Unity

how can I pass inputs via tcp to control the movement of an object in unity

Discussion in 'Scripting' started by yashvarshneyy, Jun 18, 2019.

  1. yashvarshneyy

    yashvarshneyy

    Joined:
    Mar 22, 2019
    Posts:
    2
    I am passing four instructions for the movement of a car via a TCP server. The Matlab is sending the control inputs as "left", "right", "front" and "back". If the word "left"/ "right" is passing from Matlab to unity, I want to move a car in the left/right direction. so, it should be treated as input.getaxis("horizontal").
    In the words "front"/ "back" are passed by Matlab, the car should move in the forward/backward direction. So, it should be treated as input.getaxis("vertical").
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Basically you can't set input system states from scripts, only read. You need to implement your own CustomInput.GetAxis for that or simulate actual device input for application using platform api.
     
    yashvarshneyy likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Don't use the input system on the server side for this.
     
    yashvarshneyy likes this.