Rotating Character
by Lathieeshe Thillainathan · in Torque Game Engine · 05/05/2008 (6:45 pm) · 14 replies
Hello,
I'm trying to rotate the player , when the player moves forward.
function moveforward(%val)
{
%rot = "0 1 0 90";
%pos = $Game::Player.getPosition();
$mvForwardAction = %val * $movementSpeed;
$Game::Player.setTransform(VectorAdd(%pos, %rot));
}
This only seems to just move the character, rather then rotate. Am i setting my set transform incorrectly?
Thanks
I'm trying to rotate the player , when the player moves forward.
function moveforward(%val)
{
%rot = "0 1 0 90";
%pos = $Game::Player.getPosition();
$mvForwardAction = %val * $movementSpeed;
$Game::Player.setTransform(VectorAdd(%pos, %rot));
}
This only seems to just move the character, rather then rotate. Am i setting my set transform incorrectly?
Thanks
#2
05/05/2008 (7:18 pm)
I've declared $Game::Player as a global variable. I'm just trying to rotate the player, while keeping their current position.
#3
03/25/2009 (1:24 am)
function Player::RotateAngle(%this, %obj ,%AngleVal)
{
echo("Call Player::RotateAngle(%this, %obj ,%AngleVal)");
%Pos = %obj.getTransform();
%lx = getword(%Pos,0); //Get Player X pos
%ly = getword(%Pos,1); //Get Player Y pos
%lz = getword(%Pos,2); //Get Player Z pos
%rx = getword(%Pos,3); //Get Player Rotate X pos
%ry = getword(%Pos,4); //Get Player Rotate Y pos
%rz = getword(%Pos,5); //Get Player Rotate Z pos
%angle += %AngleVal;
%rd = %angle;
//2.5 -2.5 10.0202 => -3.33124 -2.67448 10.0212
echo(%obj @ ".setTransform(x,y,z,rx,ry,rz,rd)=" SPC %lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
%obj.setTransform(%Cx SPC %Cy SPC %Cz SPC %rx SPC %ry SPC %rz SPC %rd);
}I have the same problem on TGEA 1.7.1.
#4
03/25/2009 (2:04 pm)
ccljyc ftw!
#5
06/07/2009 (3:45 am)
It may seem silly to some that ccljyc replied despite the gap between 2008/05/05 and 2009/03/25 of 8 months 20 days, but... 2 months 10 days later, ccljyc's has helped give me a lead. (Thanks ccljyc)
#6
06/07/2009 (3:47 am)
I'm actually trying to do 8-way directional player movement... Using Advanced Camera resource in Torque 3D with god view mode camera. But it's not quite working yet.// scripts/client/default.binds.cs
function moveright(%val)
{
//$mvRightAction = %val * $movementSpeed; //: GG torque code: removed
//BEGIN: City Hero Defense: UI: controls
if($moveMode == $moveMode_Normal)
{
$mvRightAction = %val * $movementSpeed;
}
else if($moveMode == $moveMode_Camera)
{
commandToServer('moveright');
$mvForwardAction = %val * $movementSpeed;
}
//END: City Hero Defense: UI: controls
}
// scripts/server/commands.cs
function serverCmdMoveRight(%client)
{
%Pos = %client.player.getTransform();
%lx = getword(%Pos,0); //Get Player X pos
%ly = getword(%Pos,1); //Get Player Y pos
%lz = getword(%Pos,2); //Get Player Z pos
%rx = getword(%Pos,3); //Get Player Rotate X pos
%ry = getword(%Pos,4); //Get Player Rotate Y pos
%rz = getword(%Pos,5); //Get Player Rotate Z pos
%transformCamera = %client.advCamera.getTransform();
%rAmt = getWord(%transformCamera, 6);
%rAmt += $PI_radians/2;
%client.player.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rAmt);
}
#7
It pretty much does it the way I suggested too, by modifying moveManager.
06/07/2009 (3:52 am)
Ah, so that's why you said you needed the explicit rotation in your other post. Well, in that case, just check out this resource. It will give you player movement dependent on the camera's direction. So when you hit up, the player moves north, hit down, south, etc.It pretty much does it the way I suggested too, by modifying moveManager.
#8
www.garagegames.com/community/forums/viewthread/50903/1#comment_form
Yea that is what I am trying to get. Although a step further is doing 8-way directional movement (instead of just 4-way). For example, wasd with w and d gives you up and right for up-right.
06/07/2009 (4:13 am)
@Mike: thanks, saw your reply here too:www.garagegames.com/community/forums/viewthread/50903/1#comment_form
Yea that is what I am trying to get. Although a step further is doing 8-way directional movement (instead of just 4-way). For example, wasd with w and d gives you up and right for up-right.
#9
So I will check this resource and see if it will help with doing it through the moveManager.h C++ code modification instead.
06/07/2009 (4:17 am)
Basically I think something is broken about my doing (the move forward part with $mvForwardAction) and (the rotating part with a server command, serverCmdMoveRight)...So I will check this resource and see if it will help with doing it through the moveManager.h C++ code modification instead.
#10
06/07/2009 (5:41 am)
Peter -- I have been watching your posts on point and click style movement and now, overhead cameras. I want to implement similar things. So far, the posts are printed out and sitting by my side, to be pieced together later, when I am more capable. However, may I please ask: --If it will not hurt your project-- would you, once you get these things done, please consider posting the finished product(s) to the resources page?
#11
Here's a post with some videos showing the camera and click-to-move stuff in action:
www.garagegames.com/community/blogs/view/17385
If you want to follow my steps (not necessarily a good idea - I'm also new to torque :-p), then you might start with just A: integrating the Advanced Camera resource into Torque 3D (or, uh join our project? we need more contributors :-p). Or, B: try using the more standard Torque 3D cameras, such as the Orbit camera. For whatever reason I've gone with A so far, but I don't want to pretend that I actually looked deeply into both and picked the better choice :-p
Does that help?
06/07/2009 (6:44 pm)
@Steve Damsky: the short answer is that I implemented the Advanced Camera resource (although Torque 3D has its own orbit camera too). Then I followed some leads on click-to-move using a mouse click ray-cast collide point.Here's a post with some videos showing the camera and click-to-move stuff in action:
www.garagegames.com/community/blogs/view/17385
If you want to follow my steps (not necessarily a good idea - I'm also new to torque :-p), then you might start with just A: integrating the Advanced Camera resource into Torque 3D (or, uh join our project? we need more contributors :-p). Or, B: try using the more standard Torque 3D cameras, such as the Orbit camera. For whatever reason I've gone with A so far, but I don't want to pretend that I actually looked deeply into both and picked the better choice :-p
Does that help?
#12
06/07/2009 (6:54 pm)
Trust me, the Advanced Camera is an excellent resource. It's the first thing I implement in any new Torque build. It's leaps and bounds better than the generic Torque camera.
#13
It seems like (absolute yaw pitch roll) could be done by instead calculating the deltas locally. But maybe that can break due to server/client not always 100% in sync.
And I wonder if it's a similar issue with (reset yaw pitch roll)...
06/07/2009 (9:25 pm)
One thing I'm confused about is whether it really makes sense to send additional 6 bits over the network to support (absolute yaw pitch roll) and (reset yaw pitch roll).It seems like (absolute yaw pitch roll) could be done by instead calculating the deltas locally. But maybe that can break due to server/client not always 100% in sync.
And I wonder if it's a similar issue with (reset yaw pitch roll)...
#14
www.garagegames.com/community/resource/view/5474/3#comments
Currently works with Advanced Camera god mode view, but only for 0 to PI (ie, my character won't walk left).
06/07/2009 (10:52 pm)
Btw, I posted some comments here about my progress:www.garagegames.com/community/resource/view/5474/3#comments
Currently works with Advanced Camera god mode view, but only for 0 to PI (ie, my character won't walk left).
Torque Owner Tyler Slabinski
Try:
I am not sure what you are trying to do, but if what I think you are doing is true, then that should help.