Client/server script variable scope confusion w/ $mvLeftAction
by Stephen Clark · in Torque Game Engine · 11/20/2003 (11:07 am) · 11 replies
So I have an item that relies on the current direction of the player which I detect via checking the $mvLeftAction, $mvRightAction, etc variables. I know these are globals, but global to both the client and the server???
Now these are only used/declared in /client/scripts, but when I play a network game, the client is using the server's move variables! I thought I had figured out client/server scope in script, but apparently not. Could anyone point me to a tutorial on that? Scope in general in script has been very confusing to me...
So how would I set this up so that each client has their own movement variables?
Thanks,
-s
Now these are only used/declared in /client/scripts, but when I play a network game, the client is using the server's move variables! I thought I had figured out client/server scope in script, but apparently not. Could anyone point me to a tutorial on that? Scope in general in script has been very confusing to me...
So how would I set this up so that each client has their own movement variables?
Thanks,
-s
#2
To detect the movement in the server you need to use server side stuff, not sure what you want to do so If you could be more precise... maybe you want to use getVelocity() which gives you a vector to which direction an object is moving.
11/20/2003 (4:43 pm)
$mv variables are used to tell the current control class to move in certain direction, this information is sent to the server and the server moves the object in it. Then the clients are updated with the new locations.To detect the movement in the server you need to use server side stuff, not sure what you want to do so If you could be more precise... maybe you want to use getVelocity() which gives you a vector to which direction an object is moving.
#3
So what is happening is that when I run a client/server on one PC and then a client on another PC the dedicated client is using the client/server's $mvxxx variables. I have an item whose onUse event depends on the current $mv variables... ie when the client/server is moving backwards, and then when the dedicated client uses the item it is using the client/server's $mv.
I'm pretty sure this is whats causing the lag icon to constantly appear on both when the client/server is moving too... Seems pretty goofy to me.
Any Ideas?
Thanks,
-s
11/21/2003 (10:00 am)
Sorry, i should have been more specific. Anytime i add stuff to my game I test it w/ a dedicated client. (from experience). My problem is happening on a dedicated client.!?So what is happening is that when I run a client/server on one PC and then a client on another PC the dedicated client is using the client/server's $mvxxx variables. I have an item whose onUse event depends on the current $mv variables... ie when the client/server is moving backwards, and then when the dedicated client uses the item it is using the client/server's $mv.
I'm pretty sure this is whats causing the lag icon to constantly appear on both when the client/server is moving too... Seems pretty goofy to me.
Any Ideas?
Thanks,
-s
#4
11/21/2003 (10:30 am)
The $mv stuff is mapped to some global variables in C++. Might it be those are being updated erroneously on the client/server?
#5
Anyone else run into this kind of problem? Anyone else use movement variables for something other than moving?
Thanks to all who replied,
-s
11/21/2003 (11:16 am)
Perhaps... I'll have to do some digging this weekend. I'll report my findings. Anyone else run into this kind of problem? Anyone else use movement variables for something other than moving?
Thanks to all who replied,
-s
#6
The onUse command is a server side function, so of course it will use the Server version of the server side global variable.
You'll want to add a new datablock function or variable to hold the current movement direction.
so the onUse function would call something like:
if (%client.backwards) {
or
if (%client.getDirection() $= "backwards) {
11/21/2003 (11:21 am)
Ahh... I know what is happening.The onUse command is a server side function, so of course it will use the Server version of the server side global variable.
You'll want to add a new datablock function or variable to hold the current movement direction.
so the onUse function would call something like:
if (%client.backwards) {
or
if (%client.getDirection() $= "backwards) {
#7
muchos gracias,
-s
11/21/2003 (11:25 am)
Ok, that makes sense... I think i did try %client.$mv or %client.mvxxx but that didnt seem to work. Should it ya think?? muchos gracias,
-s
#8
I suppose you could also get the velocity vector of the player and the muzzle vector and use that to figure out what direction the player is moving, that's the old hack I used to use in Tribes 2 (back in the day man, back in the day...)
Hope that helps,
Jeff
11/21/2003 (11:44 am)
Stephen,I suppose you could also get the velocity vector of the player and the muzzle vector and use that to figure out what direction the player is moving, that's the old hack I used to use in Tribes 2 (back in the day man, back in the day...)
Hope that helps,
Jeff
#9
But hey, I STILL play tribes 2.. not in a while, but i was addicted to renegades when I was unemployed... 420Princess
-s
11/21/2003 (1:01 pm)
Ah, see im doing an "insta-dodge" move where the player right-clicks and then whatever direction button is held down they shoot in that direction. I tried using v vector, but I want the player to be able to do it in the air as well w/o having air control. But hey, I STILL play tribes 2.. not in a while, but i was addicted to renegades when I was unemployed... 420Princess
-s
#10
Good man (for playing T2) I ran a mod called SangMOD if you remember playing it at all (it was a very small mod, made T2 much more tactics-based which really killed a lot of the potential fanbase :-P) Ever heard of the Ren clan BARX? [BARX]Sanguinus was my alias ;-)
~ Jeff
11/21/2003 (2:00 pm)
Ala Max Payne, eh :-)Good man (for playing T2) I ran a mod called SangMOD if you remember playing it at all (it was a very small mod, made T2 much more tactics-based which really killed a lot of the potential fanbase :-P) Ever heard of the Ren clan BARX? [BARX]Sanguinus was my alias ;-)
~ Jeff
#11
I am making a bomberman-esque deathmatch game w/ torque and dodging is one of the items to pick up. www.pixeldreams.com I gotta work on the website this weekend, will prob add some movies and work on the color scheme (laptop at work is NOT accurate).
-s
11/21/2003 (2:42 pm)
No, i never saw SangMOD... I played solidly for about 18 months until november of 2002. When was that mod up? I dont think I heard of /seen BARX?. I really wanted to join a clan, but I had to move and had no 'net. Man I need 'net at home so I can play again (been 2 years w/o!). I think my gf would leave me though... I already spend too much time w/ el pc w/o any net access or tribes. I loved being your friendly neighborhood anti-sniper sniper / engineer... I am making a bomberman-esque deathmatch game w/ torque and dodging is one of the items to pick up. www.pixeldreams.com I gotta work on the website this weekend, will prob add some movies and work on the color scheme (laptop at work is NOT accurate).
-s
Associate Ben Garney
But if you're running client and server on the same app, they'll be set all the time...