Jump to content
  • Advertisement
Sign in to follow this  
Dennis Heine

Problem with client side prediction

This topic is 2139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
                    }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!