I am receiving values over udp using the below code and want the gameobject to move using these values only along the x axis… but using following code gameobject only moves on mouse movement.
I am getting values over udp sockets. I just want to move the gameobject using these values only and not using mouse or keyboard…I am not able to get how to do it…
Vector3 originalPosition = cam.ScreenToWorldPoint(Input.mousePosition);
Vector3 targetPosition = new Vector3 (originalPosition.x, this.transform.position.y, 0.0f);
float xmove = Input.GetAxis("Horizontal")* Time.deltaTime * speed;
float targetWidth = Mathf.Clamp (targetPosition.x, -maxWidth, maxWidth);
targetPosition = new Vector3 (xmove,targetPosition.y,targetPosition.z);
GameObject HatSprite = GameObject.Find ("HatSprite");
ReceiveLeft = HatSprite.GetComponent<UDPDualReceive>().lastReceivedLeft;
ReceiveRight = HatSprite.GetComponent<UDPDualReceive>().lastReceivedRight;
transform.position = targetPosition;
i want to use lastReceivedLeft and lastReceivedRight to move the gamobject…