Can't Rotate by 90° character in tactic game using setTransform()
by Splouch · in Torque Game Engine Advanced · 01/25/2010 (3:28 am) · 7 replies
Hi Guys,
I've read almost every post about "rotation" in TGEA 1.7.0 and I've not found anything to solve my problem so far.
On a tactic game, I'd like to rotate my character by 90 degrees while running toward its destination. So i've used the getTransform to get the x y z and thetaRot and setTransform to rotate it but...
First, the GetTransform returned a X and Y (position) that are not my character's position at all. Even if I move this avatar, this getTransform always return the same X and Y.
Second, when I setTransform the ThetaRot (to rotate along the Y axes) nothing is happening to my character.
Here is what I did so far on the server side:
I know there are a bunch of post in the Forum about the Rotation thing, but is there anybody could help me on this ?
I thank you in advance for your help.
Splouch
I've read almost every post about "rotation" in TGEA 1.7.0 and I've not found anything to solve my problem so far.
On a tactic game, I'd like to rotate my character by 90 degrees while running toward its destination. So i've used the getTransform to get the x y z and thetaRot and setTransform to rotate it but...
First, the GetTransform returned a X and Y (position) that are not my character's position at all. Even if I move this avatar, this getTransform always return the same X and Y.
Second, when I setTransform the ThetaRot (to rotate along the Y axes) nothing is happening to my character.
Here is what I did so far on the server side:
%myTransform = %client.avatar.getTransform(); %rot1 = getWords(%myTransform,3,6); //get rotation coords x y z theta %rot2 = "0 0 1 1.74"; //set new rot coords %v1 = "0 0 0" SPC %rot1; %v2 = "0 0 0" SPC %rot2; %v3 = MatrixMultiply(%v1,%v2); %new = getWords(%myTransform,0,2) SPC getWords(%v3,3,6); %client.avatar.setTransform(%new);(and I've found those lines in another topic in the GarageGame forum)
I know there are a bunch of post in the Forum about the Rotation thing, but is there anybody could help me on this ?
I thank you in advance for your help.
Splouch
#2
It should be:
%myTransform = %client.player.getTransform(); (I believe)
01/26/2010 (12:08 am)
%myTransform = %client.avatar.getTransform(); is wrong.It should be:
%myTransform = %client.player.getTransform(); (I believe)
#3
Thank you for the interest ;-)
Unfortunately, No. There are no script error in the console log :(
For the %client.player.getTransform() instead of %client.avatar.getTransform() : We use avatar as player.
Event if I use %client.player.getTransform(), it does not find the function "getTransform()".
Using %client.avatar.getTransform() I always got "86.6025 62.5 0 0 0 1 0.4488" in the console, even if I move the player to another cell or the camera.
A friend tried the same code (adapted to the object of course) to a simple object on the same map and it worked.
I tried to change the x and y position by myself (%client.avatar.setTransformation(XX XX XX etc)) but the character didn't change. So i guess i've catched the wrong object (character). That's strange, cose any move or animation we applied to the character, we use %client.avatar
PS: in Player.h, I saw there is a function called getRotation(), but it's not present in player.cpp. So i don't know if it's another way of doing a character rotation. ANd if it is, so have to write the function.
01/26/2010 (3:15 am)
Hello guys, Thank you for the interest ;-)
Unfortunately, No. There are no script error in the console log :(
For the %client.player.getTransform() instead of %client.avatar.getTransform() : We use avatar as player.
Event if I use %client.player.getTransform(), it does not find the function "getTransform()".
Using %client.avatar.getTransform() I always got "86.6025 62.5 0 0 0 1 0.4488" in the console, even if I move the player to another cell or the camera.
A friend tried the same code (adapted to the object of course) to a simple object on the same map and it worked.
I tried to change the x and y position by myself (%client.avatar.setTransformation(XX XX XX etc)) but the character didn't change. So i guess i've catched the wrong object (character). That's strange, cose any move or animation we applied to the character, we use %client.avatar
PS: in Player.h, I saw there is a function called getRotation(), but it's not present in player.cpp. So i don't know if it's another way of doing a character rotation. ANd if it is, so have to write the function.
#4
why dont you just ask him how he did it? :)
if getTransform() isnt working for you then youre not doing something correctly. are you typing "%client.avatar.getTransform() " into the console? if so, you would need to use a global variable to do that.
01/26/2010 (3:43 am)
Quote:
A friend tried the same code (adapted to the object of course) to a simple object on the same map and it worked.
why dont you just ask him how he did it? :)
if getTransform() isnt working for you then youre not doing something correctly. are you typing "%client.avatar.getTransform() " into the console? if so, you would need to use a global variable to do that.
#5
01/26/2010 (10:52 am)
Actually we work on it together, so he tried on his side the code described above on an object then on the character. And he has the same problem as I do on the character.
#6
01/26/2010 (11:09 am)
Does your friend have a license for the engine? Your account does not and you seem to have the source code. If you have another account with a valid license please post using that account.
#7
Me setTransform work but only the bounding box rotate, the model don't rotate :/
01/26/2010 (11:11 am)
I have a same problem. i work on rotation for a object, not for the player (but may be it's the same).Me setTransform work but only the bounding box rotate, the model don't rotate :/
Torque 3D Owner Sean H.