Game Development Community

How do I ghost fxRenderObject data properly?

by Steven Peterson · in Torque Game Engine · 05/09/2008 (11:31 am) · 2 replies

Two Questions regarding a fxRenderObject variation - "myObject".

First:
I added a 'static S32 countInstances' to myObject, which gets incremented/decremented in the constructor/destructor respectivly. "countInstances" is always twice the number of instances declared in my mission-script file. If I understand Melv. May correctly there is a client and server copy of each instance created - so this IS the expected behavior, correct?

If NOT, I have a way bigger problem on my hands :-/


Second:
I have an accessor function "myObject::setVelocity(foo, bar);" which sets mFoo and mBar (with unit-conversions and error checking). Then when myObject::renderObject() =>> myObject::updateVelocity() it uses mFoo, mBar, and some neat interpolation over time to give me the end effect I desire.

It appears when I call my setVelocity(foo, bar); the changes to "mFoo" and "mBar" are made to the "server" object, but the changes are never propagated to the client side, and thus I don't see them in-game. Does this seem reasonable? How do I go about fixing it?


Thanks for any help/pointers. I'm really confused here.
Steven

Gross over-simplification for example purposes only...
class myObject : public sceneObject {
public:
void setVelocity( S32, S32);

private:
void renderObject();
void updateObject();

static S32 instanceCount;
S32 mFoo;
S32 mBar;
S32 mLastTime
};

static S32 myObject::instanceCount = 0;

myObject::myObject() { countInstance++; }
my Object::~myObject() { countInstance--; }

void myObject::setVelocity( S32 Foo, S32 Bar) { 
//More complicated, but this is the gist of it.
...
mFoo = foo;
mBar = bar;
mVelocity;
}

void myObject::renderObject( ... ) {
...
updateVelocity();
...
}

void myObject::updateVelocity() {
// 30 lines compressed into three. 
// For example only.

Time curTime = getTime()
Time dTime = curTime - mLastTime;
mVelocity = mFoo * mBar * ( dTime / mTargetTime - curTime ); 
}

#1
05/09/2008 (1:23 pm)
> If I understand Melv. May correctly there is a client and server copy of each instance created - so this IS the expected behavior, correct?

.. if you are running a single-player game, then generally yes.
one complication is that there's a concept called Network Scope which determines whether the client side needs to know about the object, and sometimes the answer is no, so you will occasionally have a server copy but no client copy.

re mFoo and mBar,
you'll want to "ghost" them to client copy.
this probably means creating a new netmask etc,
and you can read about it here: tdn.garagegames.com/wiki/Torque/Networking/Ghosting

.. yes, it is confusing, but stick with it and you'll get it.
#2
05/09/2008 (1:56 pm)
In all my research I missed this doc; I will read this and give it another go!
Thankyou!


[edit]
The solution here is to have a proper understanding of the awesome Torque-Ghosting System. This topic is fully discussed ( and indirectly, the solution to this thread) in another forum-thread that occurred on the same day.

If you need help with Torque Networking/Ghosting please read in full:
garagegames.com/mg/forums/result.thread.php?qt=75014

It will save you much pain, I promise.
Steven
[/edit]