Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


dehe

Member Since 20 Aug 2013
Offline Last Active Dec 16 2013 03:23 AM

Topics I've Started

Problem with client side prediction

14 December 2013 - 04:25 PM

Hi,

 

client side prediction is not working as intended :(

the other players char is still not walking fluently.

 

heres the code:

every 10 seconds, thread 1

//gets position of players from server
//user.isUpToDate is being set to true by server
 WorldPlayers = (Data.CharacterObjects.CPlayerInstance[])NetworkComms.SendReceiveObject<Data.CharacterObjects.CPlayerInstance[]>("RequestUWP", "192.168.1.113", 999, "UWPReply", 5000, "");
                

                





at every frame, called from main loop:^
user is the player character from WorldPlayers
(CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).newPosition is the current ppsition in the data structure
((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).m_Node.Position is the physical position of the entity



		if (!user.isUpToDate)
                {
		    //extrapolate new position if position is not up to date
                    ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).newPosition = ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).m_Node.Position(((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).m_Node.Position - ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).oldPosition);
                    user.isUpToDate = true;
                }

                     
                       
                    IrrlichtLime.Core.Vector3Df v = new IrrlichtLime.Core.Vector3Df();
                    //interpolate between current position and new position
                    v = v.Interpolate(((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).m_Node.Position, ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).newPosition, getTime() - ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).lastUpdate);
                    ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).m_Node.Position = v;
                    ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).lastUpdate = getTime()
                    
		    //if current position==new positin, start extrapolation
                    if (v == ((CCharacter)CScene.Characters.m_CCharacterWorldPlayers[user.ID]).newPosition)
                    {
                        user.isUpToDate = false;
                    }


PARTNERS