public static void receiveObject(byte[] data, out IdentityAndTransform iat) { ByteReceiver br = new ByteReceiver(data); var objectID = br.getInt(); int authorityID = br.getInt(); var type = (ObjectType)br.getInt(); var prefabIndex = br.getInt(); var pos = br.getVector3(); var rot = br.getQuaternion(); iat = NetTransportManager.instance.spawnObjectSync(prefabIndex, authorityID, pos, rot, objectID); switch (type) { case ObjectType.Planet: var mass = br.getFloat(); var linVel = br.getVector3(); var angVel = br.getVector3(); var seed = br.getInt(); var radius = br.getFloat(); UniverseManager.instance.syncPlanet(iat, mass, linVel, angVel, seed, radius); break; case ObjectType.Rigidbody: var massR = br.getFloat(); var linVelR = br.getVector3(); var angVelR = br.getVector3(); makeRigidBody(iat.instance, massR, linVelR, angVelR); break; } }
public static Vector3 getVector3(byte[] data, int startIndex) { ByteReceiver br = new ByteReceiver(data, startIndex); float x = br.getFloat(); float y = br.getFloat(); float z = br.getFloat(); return(new Vector3(x, y, z)); }
public static Quaternion getQuaternion(byte[] data, int startIndex) { ByteReceiver br = new ByteReceiver(data, startIndex); float x = br.getFloat(); float y = br.getFloat(); float z = br.getFloat(); float w = br.getFloat(); return(new Quaternion(x, y, z, w)); }
public static Color getColor(byte[] data, int startIndex) { ByteReceiver br = new ByteReceiver(data, startIndex); float r = br.getFloat(); float g = br.getFloat(); float b = br.getFloat(); float a = br.getFloat(); return(new Color(r, g, b, a)); }
public static Rigidbody getRigidbody(byte[] data, int startIndex) { ByteReceiver br = new ByteReceiver(data, startIndex); Rigidbody rb = new Rigidbody(); rb.mass = br.getFloat(); rb.velocity = br.getVector3(); rb.angularVelocity = br.getVector3(); return(rb); }