Hi,
I’d like to change the position of GameObject as
getting x, y, z from my server.
Generally this function works correctly,
but this function often makes a crash at this point.
obj.transform.position = pos;
I checked all data from server is not wrong.
Can anyone tell me what the problem of this function is?
public void S2CMove(byte[] packet, int index)
{
if(packet==null)
{
}
int uniqueID = BitConverter.ToInt32(packet, index + 4);
float x = BitConverter.ToSingle(packet, index + 8);
float y = BitConverter.ToSingle(packet, index + 12);
float z = BitConverter.ToSingle(packet, index + 16);
string objName = "id" + uniqueID;
GameObject obj = GameObject.Find(objName);
if(obj==null)
{
return;
}
Vector3 pos = new Vector3(x, y, z);
obj.transform.position = pos;
}