4 hours ago, Kylotan said:So when you say "I think state synchronisation might help my issue but it might also not", that doesn't really make sense.
I'm not sure I said that, the name state synchronisation I used is again from Glenn's page, I didn't mean it in the grammatical sense of it.
4 hours ago, Kylotan said:At this stage I think the problem is not so much of getting new ideas, it's about implementation. Most likely all your problems are at the implementation level rather than the conceptual level, but since we've seen no code or gameplay it's hard to know what they would be.
I didn't share it basically because I followed your previous explanations to write up my code so I thought it wouldn't matter but in any case here's my code:
My SetData method basically is what's called when I receive the ball's position from the server:
( the index check at first is to ensure that data arriving late isn't used )
public void SetData( NetworkBallData data )
{
if( m_LatestData.Index >= data.Index )
{
return;
}
m_PreviousData = m_LatestData;
m_LatestData = data;
if( !m_HasFinished )
{
m_PreviousData.Position = m_BallTransform.position;
m_PreviousData.Rotation = m_BallTransform.rotation;
}
if( m_PreviousDateTime == DateTime.MinValue )
{
m_PreviousDateTime = DateTime.Now;
}
else
{
DateTime now = DateTime.Now;
m_NextPositionTime = now.AddMilliseconds( CurrentDelay );
}
}
Then my Update method which is called every frame is:
( steps are used to manage packet send rate )
public void Update()
{
if( MatchManager.Instance.IsInMatch )
{
if( BattleManager.Instance.IsServer )
{
m_Step++;
if( m_Step == MultiplayerManager.PACKET_STEP )
{
m_Step = 0;
SendPosition();
}
}
else
{
DateTime now = DateTime.Now;
if( now < m_NextPositionTime )
{
m_HasFinished = false;
TimeSpan diff = m_NextPositionTime.Subtract( now );
percentage = 1.0f - diff.Milliseconds / CurrentDelay;
m_BallTransform.position = Vector3.Lerp( m_PreviousData.Position, m_LatestData.Position, percentage );
}
else
{
m_HasFinished = true;
}
}
}
}