Question about player class vs gameconnection
by Jeff Ridenour · in Torque Game Engine · 04/28/2005 (12:06 pm) · 8 replies
Hi,
Im working an a project that will allow me to overlay rotation transformations on a character on top of the existing animation playback. I've done some modifications to shapebase and animate that I believe is working. However im having a bit of trouble figuring out how to modify the actual player that is visible on a client.
If i initialize the values of all my shapeinstances to something funny, my new player looks correspondingly funny. However, if i later modify the values of my new field by accessing the player object (on the server, i believe) these values change, but the visible character does not update.
I think my problem is that the actual character shape that i can see in my view is not the same as the one that i am modifying.
So my question is, how do i access the shapebase/shapeinstance that is being rendered on the screen and is connected to the gameconnection?
Or better yet, if I have modified new fields in the shapebase of my player object, how do i make sure that those modifications update the corresponding shapebase in the client?
thanks,
jeff
Im working an a project that will allow me to overlay rotation transformations on a character on top of the existing animation playback. I've done some modifications to shapebase and animate that I believe is working. However im having a bit of trouble figuring out how to modify the actual player that is visible on a client.
If i initialize the values of all my shapeinstances to something funny, my new player looks correspondingly funny. However, if i later modify the values of my new field by accessing the player object (on the server, i believe) these values change, but the visible character does not update.
I think my problem is that the actual character shape that i can see in my view is not the same as the one that i am modifying.
So my question is, how do i access the shapebase/shapeinstance that is being rendered on the screen and is connected to the gameconnection?
Or better yet, if I have modified new fields in the shapebase of my player object, how do i make sure that those modifications update the corresponding shapebase in the client?
thanks,
jeff
About the author
#2
04/30/2005 (3:13 pm)
Okay, ive been looking at this mod, which is very helpful, and basing my changes on it. I've also modified a fresh copy of the current source with the custom shape mod, to see if i can get that to work dynamically. I can get that to work now with the option dialog changing the shape, and the new shape being loaded into the player when i start the mission, but i run into the same problem; I cant get the player to change dynamically once the mission has started. can someone verify that this works dynamically, and tell me how i can access the player object in the console, so that the player model visibly changes? (i think the problem may simply be im not trying to change the correct object...)
#3
The client calls commandToServer('SendDNA', $pref::Player::DNA, $pref::Player::skin);
If you want to set it from a script running on the server, call the %client.player.setDNA command as described on the last page of the pdf in that mod.
Make sure you have the correct %client value for the particular player object you want to change.
04/30/2005 (10:23 pm)
It does work dynamically. Are you calling it in script from the client or the server?The client calls commandToServer('SendDNA', $pref::Player::DNA, $pref::Player::skin);
If you want to set it from a script running on the server, call the %client.player.setDNA command as described on the last page of the pdf in that mod.
Make sure you have the correct %client value for the particular player object you want to change.
#4
%client.player.setScalePerBone( x, y, z , bone-index );
using this should work, right? or do i need to use the setdna command?
What is the best way to get the correct %client, %client.player value?
04/30/2005 (10:46 pm)
Before I was actually writing a script, I was just typing commands in the console, so that i understand what is going on. (which i dont quite yet) As stated in the last page of the pdf, i was using this function below:%client.player.setScalePerBone( x, y, z , bone-index );
using this should work, right? or do i need to use the setdna command?
What is the best way to get the correct %client, %client.player value?
#5
ClientSide
ServerSide
04/30/2005 (10:58 pm)
Yeah jeff that would work in script but not on the console, the reason is the console is the client, and the client has no clue what %client means. However if you put that into a server side script, it should work fantastically. (Assuming of course you are passing in the client object properly.ClientSide
CommandToServer('MyBoneFunction',%MyValues);ServerSide
ServerCmdMyFunction(%client,%values){
%client.setscaleperbone(%values);
}
#6
should work fine. The setDNA calls it anyway. The difference is setDNA has a string of ( x, y, z , bone-index ) values which it then breaks down into individual setScalePerBone calls.
For testing in the console, I don't know if there is a clever way to get the object id of the player you need. You don't need the %client value if you have the object id of that client's player shape at hand.
I think when a player-shape is created, the object id is written to the log file which you can access with the ~ button.
04/30/2005 (10:59 pm)
%client.player.setScalePerBone( x, y, z , bone-index );should work fine. The setDNA calls it anyway. The difference is setDNA has a string of ( x, y, z , bone-index ) values which it then breaks down into individual setScalePerBone calls.
For testing in the console, I don't know if there is a clever way to get the object id of the player you need. You don't need the %client value if you have the object id of that client's player shape at hand.
I think when a player-shape is created, the object id is written to the log file which you can access with the ~ button.
#7
04/30/2005 (11:02 pm)
Could also try using the tree(); command and looking for the Player buried deep in there.
#8
I am getting a handle on the player one way or another (either looking at the object in the editor to get the handle, or setting a global variable when the player is created by the server) and calling .setDNA on that handle. setDNA works as I expect, so i am able to change things dynamically. However the setScalePerBone does not do anything or what I expect.
Am I correct in thinking that:
$myplayer.setDNA("000 1.50 0.50 0.50 ");
and
$myplayer.setScalePerBone(1.5, 0.5, 0.5, 0);
should accomplish the same thing? because they don't, at least in my code. anyways at least im unstuck now, and can work on writing my scripts. thanks a lot,
jeff
04/30/2005 (11:13 pm)
Okay, well I am unstuck at least now.I am getting a handle on the player one way or another (either looking at the object in the editor to get the handle, or setting a global variable when the player is created by the server) and calling .setDNA on that handle. setDNA works as I expect, so i am able to change things dynamically. However the setScalePerBone does not do anything or what I expect.
Am I correct in thinking that:
$myplayer.setDNA("000 1.50 0.50 0.50 ");
and
$myplayer.setScalePerBone(1.5, 0.5, 0.5, 0);
should accomplish the same thing? because they don't, at least in my code. anyways at least im unstuck now, and can work on writing my scripts. thanks a lot,
jeff
Torque Owner Dreamer
Default Studio Name