Jump to content
  • Advertisement

Tipotas688

Member
  • Content count

    357
  • Joined

  • Last visited

Community Reputation

87 Neutral

1 Follower

About Tipotas688

  • Rank
    Member

Personal Information

  • Website
  • Role
    Business Development
    Programmer
    Technical Director
  • Interests
    Business
    Programming

Social

  • Twitter
    @terahardstudios

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Tipotas688

    Snapshot Interpolation

    So in the end I decided I should use something simpler than EPIC, sorry @hplus0603 and went with the much simpler m_PotentialData.Position = m_LatestData.Position + ( m_LatestData.Position - m_PreviousData.Position ); basically, x2 = x1 + v0 for now for simplicity. My current problem is that debugging has just gotten a lot more difficult. I have had set a delay as @Kylotan explained in the beginning of this post, around 30ms and used that to lerp into the future, as extrapolation I set it as 60ms so 30ms extra. I noticed that 1) I wasn't taking into account rendering time which also was 30ms ( in a 30 fps scenario ) which had as a result jittering so I increased this into 90ms as a base and 180ms for extrapolation. That had the very negative effect that we get packets a lot more often before reaching the target and thus as you can see in my code in previous pages I don't try to reach the final point rather update to the new point: if( !m_HasFinished ) { m_PreviousData.Position = m_BallTransform.position; m_PreviousData.Rotation = m_BallTransform.rotation; } so my question is, do I speed up the lerp? do I send packets slower? do I queue up each packet so that I reach the end point each time?
  2. Tipotas688

    Snapshot Interpolation

    @Kylotan I almost didn't recognise you with your new profile pic Sure, normally I should use probably the server's time that is definitely checking the time in it's own system to have a globally synchronised time which is why I'm trying a simplified approach to see first if it works. the problem is this: I'm not adding the extrapolated data, unless it's doing it automatically but as I mentioned above I was getting some crazy big numbers as a result so I couldn't really make sense what was supposedly returned. But because of oPos = m_SnapPos + oVel * (float)( forTime - m_SnapTime ); when it's called in AddSample m_SnapPos becomes a huge number like (-49336320.0, -49336320.0, 0.0) Since that post I actually found this: https://github.com/Relfos/EPICSharp which others can use as well if they ever manage to go through all these messages
  3. Tipotas688

    Snapshot Interpolation

    I made an example script that shows my results: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Object = UnityEngine.Object; public class ExtrapolatorExample : MonoBehaviour { private Extrapolator3 m_Extrapolator3 = new Extrapolator3(); private DateTime m_PressTime; private int m_Step = -1; private const int STEP_COUNT = 30; private Vector3 m_ClickData = new Vector3(); void Update() { if( Input.GetMouseButtonDown( 0 ) ) { m_ClickData = Camera.main.ScreenToWorldPoint( Input.mousePosition ); CreateDebugCube( m_ClickData, Color.blue ); m_PressTime = DateTime.Now; m_Step = STEP_COUNT; } if( m_Step > 0 ) { m_Step--; } else if( m_Step == 0 ) { m_Step--; bool done = m_Extrapolator3.AddSample( m_PressTime.Ticks, DateTime.Now.Ticks, m_ClickData ); Debug.Log( done + " " + m_ClickData ); Vector3 data; bool read = m_Extrapolator3.ReadPosition( m_PressTime.Ticks + STEP_COUNT, out data ); Debug.Log( read + " " + data ); CreateDebugCube( data, Color.yellow ); } } private List<GameObject> m_TempList = new List<GameObject>(); private void CreateDebugCube( Vector3 data, Color color ) { GameObject temp = GameObject.CreatePrimitive( PrimitiveType.Cube ); temp.transform.position = new Vector3( data.x, data.y, -5 ); temp.transform.localScale = Vector3.one * 0.5f; temp.name = "Cube " + m_TempList.Count; Object.Destroy( temp.GetComponent<BoxCollider>() ); temp.GetComponent<Renderer>().material.shader = Shader.Find( "VertexLit" ); temp.GetComponent<Renderer>().material.color = color; m_TempList.Add( temp ); } }
  4. Tipotas688

    Snapshot Interpolation

    oPos = m_SnapPos + oVel * (float)( forTime - m_SnapTime ); This is the part which I understand the least, time is unit dependent since it's differentiation rather than a % so if I use ticks which are 10000 times a millisecond the number returned is huge. One second it can be: (1.0, -2.7, 0.0) = (1.0, -2.7, 0.0) + (0.0, 0.0, 0.0) * ( 6.36594027695935E+17 - 6.36594027694191E+17 ) and the next second it's: (-17777810000.0, -30792030000.0, 0.0) = (1.0, -2.7, 0.0) + (0.0, 0.0, 0.0) *(6.58622968946338E+17 - 6.36594027695935E+17 ) Also oVel can a lot of the time be 0 since a user might not move for some time and that returns a zero vector at first since m_SnapPos will also stay zero and that creates a weird problem where the potential extrapolated position is 0,0,0 which is wrong
  5. Tipotas688

    Snapshot Interpolation

    @hplus0603 following a few days of reading and testing I got a question: I did try your logic above but it didn't really work, mostly because T2-T1 wasn't relevant to the positions so somewhere along the way I didn't get correct positions, I implemented the EPIC solution in C# which seems to give me some results but their explanation for some reason doesn't make sense to me: I don't understand why it should be less, if it's less than the last curTime which is basically now as you update the same and calculate the next potential position you'll get a time difference that ends before the interpolation does.
  6. Tipotas688

    The Poor Man's Netcode

    @evanofsky I'm in the process of doing something similar, kinda have been at it at the past year and now it's lag that I'm trying to combat! I was trying to find a generic solution to it but when I read your post that each ability needs it's own "fix" it got me worried
  7. Tipotas688

    Snapshot Interpolation

    Yeap, I understand that part of the concept but the part I don't is where you said: but if when receiving the latest data is where I decide if the packet has arrived in good time so I interpolate or it's too slow so I extrapolate, it kinda makes interpolation redundant. Unless you were aiming for something different. As far as I understand your idea to add extrapolation in my interpolation-only solution so far is: During the update, if it's been too long after the now + delay, I extrapolate if not then I interpolate as I have been. When I receive data from the server I update the information as well as the future potential position if the next packet is delayed.
  8. Tipotas688

    Snapshot Interpolation

    @hplus0603 I'm a bit lost, the reason I'm keeping whether it has finished interpolating is in case a packet arrives before my interpolation to the "present" has finished. If that happens it means my fake delay is too long and I could reduce it. As I understand, in your example P2 is a future potential position so I'm predicting but do I do that in case a packet is late or do I do it regardless? I actually had this epic link and I've already started converting the code to C#
  9. Tipotas688

    Snapshot Interpolation

    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. 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; } } } }
  10. Tipotas688

    Snapshot Interpolation

    Sure I meant that I'll try both and see which works best for my game. I just think that state synchronisation might wield better results although honestly "cheating" with deterministic lockstep is the easiest way to go and I'm worried if I don't manage good results for pong that could be the best alternative. Where can I go after that? The more I learn the more ideas I might come up with for my solutions.
  11. Tipotas688

    Snapshot Interpolation

    @JM-KinematicSoup we too have catered for multithreaded serialisation and I've done some checks, even on mobile we get something like 100-300 ticks and 0ms plus I have added delta compression and quaternion compression to have our packet be as tiny as possible. Server wise we use rUDP for performance. I chose to go with snapshot interpolation rather than deterministic lockstep because it felt a better technique for a generic multiplayer library and even though it might be ok, quoting Glenn Fiedler deterministic lockstep is not good with floating point determinism which again won't help our library which is to work multi-platform in PC, consoles and mobile. He also comments that it doesn't scale very well with a lot of players as you can't wait for them to send input to continue. Rather than extrapolation which I will be trying anyway for predictions etc I think state synchronisation might help my issue but it might also not.
  12. Tipotas688

    Snapshot Interpolation

    That is some great info there! Thanks a bunch! I had the above in mind but someone verifying them is actually great. I'll be re-reading this answer a few times as I'm working out the details on the kinks of server to master server to client and back. Fingers crossed I get better understanding on where bottlenecks happen so I have more educated answers to my questions.
  13. Tipotas688

    Snapshot Interpolation

    Sure, I have read it but since I'm new to network coding I want to make sure I grasp some of the main concepts before I add more to my plate
  14. Tipotas688

    Snapshot Interpolation

    Sure I'm with you, I think I'm reaching the same conclusion that extrapolation is required. The test game I'm making ( pong ) is sending 30 packets a second, basically every frame to make sure I get the best result possible. If I lose a packet I use the next one, if there's a delay I snap to it. What I notice is that a user that has 100ms delay plays with issues that are game breaking, a user that has 60ms plays much better. Being a pong game it needs accuracy to play ok and as you say there are trade-offs but I'm currently not seeing great results even though I have such low latencies. Makes me wonder whether a game like pong can be done with just snapshot interpolation or whether it also needs extrapolations as well
  15. Tipotas688

    Snapshot Interpolation

    @Kylotan took me some time to reply to your last message as we were really busy with the release of our new game but now I can get back to this and give it another look. What you're saying is correct, maybe I didn't phrase it properly to explain what my issue is. The example I've picked for the above in case I haven't mentioned was making a pong game which needs to be pretty accurate. I've made the system to be what you suggested but even with the variable N depending on lag but because of the ~50ms of delay the "rackets" in a lot of cases don't reach in time basically breaking the gameplay. My question is mostly whether snapshot interpolation can actually be used in skill games which accuracy is important or should I be looking into something more complex?
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!