SetMoveDestination
by Tasty Green Pees :-, · in General Discussion · 04/05/2006 (2:59 am) · 10 replies
Can anyone explain why i persist to get this error:
this is where it is being called:
game/server/scripts/commands.cs (78): Unknown command setMoveDestination. Object (1378) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject
this is where it is being called:
function serverCmdmoveTo(%client, %obj)
{
%eyeVec = %client.player1.getEyeVector();
%startPos = %client.player1.getEyePoint();
%endPos = VectorAdd(%startPos, VectorScale(%eyeVec, 1000));
%mask = ($TypeMasks::TerrainObjectType);
%target = ContainerRayCast(%startPos, %endPos, %mask);
if (%target)
{
%xx = getWord(%target, 1);
%yy = getWord(%target, 2);
%zz = getTerrainHeight(%xx SPC %yy);
%drop = 3;
%finalPos = %xx SPC %yy SPC %zz + %drop;
if(%client.getControlObject() $= %client.player1) {
%client.player2.setMoveDestination(%finalPos);
//OnReachDestination(...)
} else {
%client.player1.setMoveDestination(%finalPos);
//OnReachDestination(...)
}
} else {
echo("CANNOT MOVE");
}About the author
#2
Hence it is possible to access player1 for example thus: %client.player1
I've been able to swtich between players and and when I use setTransform instead of setMoveDestination it work perfectly.
I think u might be right about setMoveDestination not working for Player object but why would this be? It doesn't seem to make sense if setTransform works. I'm sure that there must be a function or means by which to tell a client object to move somewhere.
Oh yeah-- I'm trying to move the Player NOT the AiPlayer.
04/05/2006 (6:52 am)
Player1 and player2 are objects controlable by the client. in my game u have 2 character and u can switch between them.Hence it is possible to access player1 for example thus: %client.player1
I've been able to swtich between players and and when I use setTransform instead of setMoveDestination it work perfectly.
I think u might be right about setMoveDestination not working for Player object but why would this be? It doesn't seem to make sense if setTransform works. I'm sure that there must be a function or means by which to tell a client object to move somewhere.
Oh yeah-- I'm trying to move the Player NOT the AiPlayer.
#3
04/05/2006 (6:56 am)
Change your Players to AIPlayers. AIPlayer is derived from Player, so when you set one as the control object you get all the normal functionality of a player and you'll get access to moveTo.
#4
04/05/2006 (7:00 am)
Lemme try this...
#5
04/05/2006 (7:04 am)
Worked ! thanks stefan and scott. that was a sweet one-two combo ; )
#6
Glad you got it working.
AIPlayer has setMoveDestination, while player does not - this is because Players are just Players that are controlled by the client, not by the server.
04/05/2006 (9:06 am)
Oh yeah I didn't spot the %client variable in there (: You're correct.Glad you got it working.
AIPlayer has setMoveDestination, while player does not - this is because Players are just Players that are controlled by the client, not by the server.
#7
I am using the RPGDialog resource, and these are the 2 functions:
function PlayerMoveTo(%position,%client,%sender,%npcFile)
{
%client.player.setAimLocation(%position);
%client.player.setMoveDestination(%position);
CloseDialog(%client,%sender,%npcFile);
}
function MoveTo(%position,%client,%sender,%npcFile)
{
%sender.setAimLocation(%position);
%sender.setMoveDestination(%position);
CloseDialog(%client,%sender,%npcFile);
}
It works fine for the sender (MoveTo), but not for the player character (PlayerMoveTo). Does anyone have any suggestions for this?
04/13/2006 (2:32 pm)
I am actually having a similar problem with this. I have changed my Player to an AIPlayer, but he still won't move.I am using the RPGDialog resource, and these are the 2 functions:
function PlayerMoveTo(%position,%client,%sender,%npcFile)
{
%client.player.setAimLocation(%position);
%client.player.setMoveDestination(%position);
CloseDialog(%client,%sender,%npcFile);
}
function MoveTo(%position,%client,%sender,%npcFile)
{
%sender.setAimLocation(%position);
%sender.setMoveDestination(%position);
CloseDialog(%client,%sender,%npcFile);
}
It works fine for the sender (MoveTo), but not for the player character (PlayerMoveTo). Does anyone have any suggestions for this?
#8
in server/scripts/commands.cs
to call the function just add this to client/scripts/default.bind.cs
Though I think u might be trying to do something a little different, u can use this as a reference and i think it will work.
04/14/2006 (1:28 am)
Here is my entire function. It works. Just remember that my player is controlling (interchangably) 2 aiplayers. So when the user is controlling or "emboding" "player1" then it will be "player2" that moves and vica versa.in server/scripts/commands.cs
//----------------------------------
// MOVE TO
//----------------------------------
function serverCmdmoveTo(%client, %obj)
{
%pointer = %client.getControlObject(); // this is the player the user is currently controlling
%eyeVec = %pointer.getEyeVector();
%startPos = %pointer.getEyePoint();
%endPos = VectorAdd(%startPos, VectorScale(%eyeVec, 1000));
%mask = ($TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType);
%target = ContainerRayCast(%startPos, %endPos, %mask);
if (%target) {
%xx = getWord(%target, 1);
%yy = getWord(%target, 2);
%zz = getTerrainHeight(%xx SPC %yy);
%finalPos = %xx SPC %yy SPC %zz;
// if the controlled player is player1 than tell player2 to move
if(%pointer $= %client.player1) {
if(%client.player2.getControlObject()) {
jumpOff(%client.player2);
}
%client.player2.setMoveDestination(%finalPos);
//OnReachDestination(...)
} else {
// if the controlled player is player2 than tell player1 to move
if(%pointer $= %client.player2) {
if(%client.player1.getControlObject()) {
jumpOff(%client.player1);
}
%client.player1.setMoveDestination(%finalPos);
//OnReachDestination(...)
}
}
} else {
echo("CANNOT MOVE");
}
}to call the function just add this to client/scripts/default.bind.cs
moveMap.bindCmd(keyboard, "shift f", "commandToServer('moveTo', "");Though I think u might be trying to do something a little different, u can use this as a reference and i think it will work.
#9
04/14/2006 (11:32 am)
Thanks, Tasty Green Pees; so, basically, it works when the player is not the control object?
#10
04/14/2006 (12:18 pm)
I've got it working; I just changed the control object. Thanks for your help! :D
Torque Owner Stefan Lundmark
I don't think Players can use setMoveDestination().
Also, you might already know this, but the code above is really broken.
You haven't defined player1 anywhere, nor have you sent it as an argument to the function.
There's another bunch of oddities in there, but I'm sure you can spot em.
This might be useful.