TimeOfDay not synched between clients
by Devin Passage · in Torque 3D Professional · 08/01/2010 (7:33 am) · 2 replies
Hmmm, here is where the TimeOfDay is supposed to advance itself, problem is, I don't see advanceTime getting called on the server TOD object. As a matter of fact, I don't think AdvanceTime is a server side function, I think its reserved for client side animations, which is well and good but somewhere the time needs to get advanced on the server.
Any ideas? Thanks.
Any ideas? Thanks.
void TimeOfDay::advanceTime( F32 dt )
{
if ( !mPlay )
return;
F32 elevation = mRadToDeg( mElevation );
bool daytime = false;
if ( elevation > 350.0f || ( 0.0f <= elevation && elevation < 190.0f ) )
{
dt *= mDayScale;
daytime = true;
}
else
{
dt *= mNightScale;
daytime = false;
}
//Con::printf( "elevation ( %f ), ( %s )", elevation, ( daytime ) ? "day" : "night" );
// do time updates
mTimeOfDay += dt / mDayLen;
// It could be possible for more than a full day to
// pass in a single advance time, so I put this inside a loop
// but timeEvents will not actually be called for the
// skipped day.
while ( mTimeOfDay > 1.0f )
mTimeOfDay -= 1.0f;
_updatePosition();
if ( isServerObject() )
_updateTimeEvents();
}About the author
www.martianarctic.com
#2
Remove the whole AdvanceTime block.
To the constructor, add
mAnimateSpeed = 1.0f;
mAnimateTime = 1.0f;
add the following function:
also to the header add
int mAmimateSpeed;
int mAnimateTime;
public:
virtual void processTick( const Move *move );
There ya go! Synched time of day.
08/01/2010 (5:13 pm)
Excellent, thank you David! I'll go ahead and post Konrad's fix here, so that the fix appears when you search the forums for TimeOfDay :pRemove the whole AdvanceTime block.
To the constructor, add
mAnimateSpeed = 1.0f;
mAnimateTime = 1.0f;
add the following function:
void TimeOfDay::processTick( const Move *move )
{
if ( !mPlay )
{
_updatePosition();
return;
}
F32 dt = TickSec;
F32 elevation = mRadToDeg( mNextElevataion );
if ( elevation > 350.0f || ( 0.0f <= elevation && elevation < 190.0f ) )
dt *= mDayScale;
else
dt *= mNightScale;
if ( mAnimateTime != -1.0f )
{
F32 target = mAnimateTime;
F32 cur = mRadToDeg( mNextElevation );
if ( target < cur )
target += 360.0f;
F32 dif = target - cur;
F32 scale = mAnimateSpeed * mClampF( mPow( dif / 15.0f, 2 ), 0.1f, 1.0f );
dt *= scale;
}
//Con::printf( "elevation ( %f ), ( %s )", elevation, ( daytime ) ? "day" : "night" );
// do time updates
mTimeOfDay += dt / mDayLen;
// It could be possible for more than a full day to
// pass in a single advance time, so I put this inside a loop
// but timeEvents will not actually be called for the
// skipped day.
while ( mTimeOfDay > 1.0f )
mTimeOfDay -= 1.0f;
_updatePosition();
_updateTimeEvents();
}also to the header add
int mAmimateSpeed;
int mAnimateTime;
public:
virtual void processTick( const Move *move );
There ya go! Synched time of day.
David McDonald
Bad Uncle Games
We had a similar issue with a dedicated server and the clients not syncing.
This thread addressed a couple of the points:
www.torquepowered.com/community/forums/viewthread/116925
Following the feedback here our clients all sync to the dedicated server.