void OnEnable() { // Connect to target machine source = NeuronConnection.Connect(address, port, commandServerPort, socketType); // Get first actor from source actor = source.AcquireActor(0); }
protected override void UpdateState() { if (_instance == null) { } else if (!Connect) { //NeuronConnection.Disconnect(_instance); //_instance = null; } if (_instance == null) { return; } if (_actor == null || _actor.actorID != ActorID) { _actor = _instance.AcquireActor(ActorID); } if (_actor == null) { return; } if (Body.GetPersistentEventCount() == 0) { return; } _instance.OnUpdate(); _body.Head.Position = _actor.GetReceivedPosition(NeuronBones.Head); _body.Head.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.Head)); _body.Neck.Position = _actor.GetReceivedPosition(NeuronBones.Neck); _body.Neck.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.Neck)); _body.Chest.Position = _actor.GetReceivedPosition(NeuronBones.Spine2); _body.Chest.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.Spine1) + _actor.GetReceivedRotation(NeuronBones.Spine2) + _actor.GetReceivedRotation(NeuronBones.Spine3)); _body.Waist.Position = _actor.GetReceivedPosition(NeuronBones.Hips); _body.Waist.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.Hips)); _body.LeftArm.shoulder.Position = _actor.GetReceivedPosition(NeuronBones.LeftShoulder); _body.LeftArm.shoulder.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftShoulder)); _body.LeftArm.Clavicle.Position = _actor.GetReceivedPosition(NeuronBones.LeftArm); _body.LeftArm.Clavicle.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftArm)); _body.LeftArm.Elbow.Position = _actor.GetReceivedPosition(NeuronBones.LeftForeArm); _body.LeftArm.Elbow.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftForeArm)); _body.LeftArm.wrist.Position = _actor.GetReceivedPosition(NeuronBones.LeftHand); _body.LeftArm.wrist.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftHand)); _body.RightArm.shoulder.Position = _actor.GetReceivedPosition(NeuronBones.RightShoulder); _body.RightArm.shoulder.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightShoulder)); _body.RightArm.Clavicle.Position = _actor.GetReceivedPosition(NeuronBones.RightArm); _body.RightArm.Clavicle.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightArm)); _body.RightArm.Elbow.Position = _actor.GetReceivedPosition(NeuronBones.RightForeArm); _body.RightArm.Elbow.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightForeArm)); _body.RightArm.wrist.Position = _actor.GetReceivedPosition(NeuronBones.RightHand); _body.RightArm.wrist.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightHand)); _body.LeftLeg.Hip.Position = _actor.GetReceivedPosition(NeuronBones.LeftUpLeg); _body.LeftLeg.Hip.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftUpLeg)); _body.LeftLeg.knee.Position = _actor.GetReceivedPosition(NeuronBones.LeftLeg); _body.LeftLeg.knee.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftLeg)); _body.LeftLeg.foot.Position = _actor.GetReceivedPosition(NeuronBones.LeftFoot); _body.LeftLeg.foot.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.LeftFoot)); _body.RightLeg.Hip.Position = _actor.GetReceivedPosition(NeuronBones.RightUpLeg); _body.RightLeg.Hip.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightUpLeg)); _body.RightLeg.knee.Position = _actor.GetReceivedPosition(NeuronBones.RightLeg); _body.RightLeg.knee.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightLeg)); _body.RightLeg.foot.Position = _actor.GetReceivedPosition(NeuronBones.RightFoot); _body.RightLeg.foot.Rotation = Quaternion.Euler(_actor.GetReceivedRotation(NeuronBones.RightFoot)); Body.Invoke(_body); }