Initialize a field of a server object as well as all client objects.
by David Hahnert · in Torque Developer Network · 07/14/2009 (7:37 pm) · 1 replies
I need to create an object on the server, initialize and set a var inside of it during load time in such a way so that when all clients join and load their copy of this server object they know the value of this variable as well.
Please Note that I am currently using ghosting as a workaround, it is insufficient because no matter when I choose to 'update' this var to the clients it is either too soon and the client has not loaded this object yet (an AI player not a mission object so I sometimes see it physically loading after I have entered the game) or too late and I've already started making calls that need this var after the object has been loaded in. ( i need it on ray casting for the mouse over event).
Also Note: this var never needs to be updated again after the clients get it.
Thank you
networking,client,server,ghost,load
Please Note that I am currently using ghosting as a workaround, it is insufficient because no matter when I choose to 'update' this var to the clients it is either too soon and the client has not loaded this object yet (an AI player not a mission object so I sometimes see it physically loading after I have entered the game) or too late and I've already started making calls that need this var after the object has been loaded in. ( i need it on ray casting for the mouse over event).
Also Note: this var never needs to be updated again after the clients get it.
Thank you
networking,client,server,ghost,load
David Hahnert
All I had to do was:
1. add a new value into the class I wanted
2. initialize it in its persistent fields function and in the constructor
3. write the value in the pack function
4. read the value in the unpack function
And then I was able to start reading this value on the client as soon as it was initialized. Now in my case this value never changes so unfortunately it will now keep updating this value when it updates this object. However, this is still much better than my ghosting work-around.