A second client observer
by gamer · in Torque Game Engine · 12/22/2006 (1:20 pm) · 1 replies
I want to make an observer client whose camera is constantly looking at the main player. what's the best practice here? I am thinking about passing the camera position&infos from the main player to the observer camera constantly. is this the right track?
thanks
thanks
About the author
Torque Owner gamer
To reiterate what I want to do: a client who can can observe another client player.
in server/scripts/game.cs: function GameConnection::onClientEnterGame(%this) { ... // Create a new camera object. %this.camera = new Camera() { dataBlock = Observer; }; MissionCleanup.add( %this.camera ); %this.camera.scopeToClient(%this); // Create a player object. if(%this.isObserver){ %this.setControlObject(%this.camera); } else %this.spawnPlayer(); if(%this.isObserver){ //grab camera transform from another client's player requestObservation(%this); } } function requestObservation(%client){ //error("client "@%client @" request observation"); for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) { %cl = ClientGroup.getObject( %clientIndex ); if(%cl.isObserver)continue; if(%cl == %client)continue; commandToClient(%client, 'acceptObservation',%cl.getCameraObject().getTransform()); } if(isObject(%client)){ schedule(100, 0, "requestObservation",%client); } } on client: function clientCmdAcceptObservation(%cameraTransform){ %cl=ServerConnection; %camera=%cl.getCameraObject(); if(isObject(%camera)){ error("clientCmdAcceptObservation "@%cameraTransform); //%camera.clearControlObject(); %camera.setTransform(%cameraTransform); //%cl.setControlObject(%camera); //%camera.mode=toggleCameraFly; } }so first I start the game and enter my main player on machine 1, then
something strange is happening when I enter the game as an observer client on machine 2, it keeps flickering, as if the camera position is being changed back and forth. at one moment the observer's camera is at the main player's feet where it should be, the next moment it's being set to another unknown position. I dont know who else is changing the camera. It looks like that some other code is also manipulating the camera. any idea what might went wrong?
thanks