Camera rotation?
by Kaya Dogan · in Torque Game Engine Advanced · 08/06/2006 (3:38 am) · 5 replies
We want our camera act like the camera in Star Wars Galaxies, so when the player doesn't move, he should be able to rotate the camera around the player model - as often as he wants to. << solved this one :D
Second problem we have is that for example if the camera faces the player's front and the player starts moving, the camera gets set begind the player, but we want the player to turn instead of the camera.
If someone would help, that would be great. We need to get the camera working, cause the camera is a critical part of the overall gameplay.
Second problem we have is that for example if the camera faces the player's front and the player starts moving, the camera gets set begind the player, but we want the player to turn instead of the camera.
If someone would help, that would be great. We need to get the camera working, cause the camera is a critical part of the overall gameplay.
#2
08/06/2006 (6:39 am)
Hmmm...doesn't work here..we use the starter.fps (TSE port)...hmm...I wonder if the starter.fps needs to be modified in order to get it working.
#3
The script above is default.bind.cs from the client/scripts folder in the TSE demo folder.
08/06/2006 (7:06 am)
In game.cs in the server/scripts folder in the TSE demo folder, see how I named the player 'player'.// Create the player object
%player = new Player(player) {
dataBlock = LightMaleHumanArmor;
client = %this;
};
MissionCleanup.add(%player);The script above is default.bind.cs from the client/scripts folder in the TSE demo folder.
#4
08/06/2006 (7:38 am)
Ah yeah - thx Anton. Now it works - I'll tweak it a bit now. I owe you one ;)
#5
08/07/2006 (2:06 am)
My pleasure
Torque Owner Anton Bursch
// the move forward function function moveforward(%val) { // get the player's eye transform or where they are looking %playerEyeTransform = player.getEyeTransform(); // get the player's position %position = player.getPosition(); // set vector for storing the player's eye transform rotation which is 3,4,5 %rotationVec = getWords(%playerEyeTransform, 3, 5); // set the amount of rotation of the player's eye transform %rotationTheta = getWord(%playerEyeTransform, 6); // now set the player's transform to it's position, the eye transform's rotation vector and amount of rotation player.setTransform(%position SPC %rotationVec SPC %rotationTheta); // move forward $mvForwardAction = %val; }it's sloppy, but it should get you moving along. i used it for a proof of concept demo.
the important thing here is that it is your attached camera has control of the eye transform, not the player model, so, you are getting that eye transform from where you camera is looking and setting the player model to face that same direction while keeping the player's same position, of course. this is a very sudden change in orientation for the player, and you probably want to do something to smooth the transition out.