Jump to content
  • Advertisement

Webzen

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

138 Neutral

About Webzen

  • Rank
    Newbie

Personal Information

  • Interests
    |programmer|
  1. I am still stuck on this and feel like I am making no progress by myself. I've been stuck at fiddling around with stuff but still cannot get rid of the jitter. My previous topic is here. I know that I need to find the difference in time between packets, from hplus's code here. I am just so confused about the "previousState" and "nextState" states and their ".time" property. For example I am using Godot and have this code to interpolate a player to a new position. Positional data is being sent 15 times a second, and received 15 times a second, on my local server.  var _velocity = Vector2(0,0) var SPEED = 1000 func _process(delta): if new_pos.x: var my_pos = get_pos() var vector = new_pos - my_pos var length = floor(vector.length()) var direction = vector.normalized() if length < 2: if length < 0.5: _velocity = Vector2(0,0) # full stop. else: _velocity = vector * SPEED * delta else: _velocity = vector * SPEED * delta func _integrate_forces(state): if new_pos.x: state.set_linear_velocity(_velocity) So, the new_pos is the property that is being updated 15 times a second from the server. The delta here is 0.0167. Game is running at 60 fps (1/60). _process is being updated at that rate, 60 times a second.   My problem is, since I am only sending 15 positional packets per second to the server, that means I need to do some type of interpolation.    I could... instead of having that code in the _process method that runs at (60 times/s), have that code only run when the packets are received. Which would be essentially 15 times per second. But, if any lag would happen, would make the character jump all over the place because we're updating the linear_velocity.    Now, on to hplus` answer, I need to find the time difference between packets. So I have a variable called "last_message_sent" and "last_message_received".  If I am understanding this correctly, I now can get the difference (t) between packets and use that in my delta, right?  To make it dynamic so that the jitter doesn't happen, but am unsure how to go about doing that. This is where my brain just gets stuck, thus this thread is created :X   e: I don't know where I went wrong..
  2. I've been stuck all day on this unfortunately.  Problem in action: https://i.gyazo.com/a13cdb3c2f318bec1559ca8011e2763b.mp4 I'm basically simulating a 10/second positional update from the server: It updates the new_pos Vector2 with x, y values 10 times a second. Game is running at 60 fps and I am trying to interpolate the character movement. And, the lerping code: if new_pos.x: var lerpspeed = 0.5 set_pos(Vector2(lerp(get_pos().x, new_pos.x, lerpspeed), get_pos().y)) I'm using the Godot engine by the way (GDScript language) I've been searching these forums and read that my lerpspeed somehow needs to be dynamic and clamped between 0.1 - 1.  I'm just not entirely sure how to go about doing that. Thanks in advance
  3. ..and no P2P movement it is.  :lol: 100 concurrent players online would be amazing. I'm going to use your conservative points about only sending the data when players are in range, if the player is even moving, etc.  So looks like the 15 msgs in/out + host server + interpolated movement  is ideal for me. Not as reactive as I'd like at 15.. I might up it a bit.. I'll do more testing and might create a new thread later if I got a whole new issue :P 
  4. Wow, you guys are loaded with information. Much more than I can ever attain. Am bookmarking this thread for future references.    Now, I was thinking a bit about this overnight.  What if I made it so I still have a host, items are server-side, cooldowns, etc all the same as before. Except there is a catch. What if player movement was done via P2P? This would drastically remove some overhead, right? Obviously this would open a yuuge can of worms in terms of fly hacking. But, this would drastically remove the overhead, and make the game seem even smoother than how I am currently interpolating x,y positions.  However, there has to be a big drawback to this which I'm probably not thinking of...  :ph34r:
  5. Thanks hplus and Kylotan. This forum is pretty damn helpful.. for me just being a new user and you guys responding within minutes. I've gone ahead with a 10-15 messages per second timer. It basically sends x, y and some other small information to the server. Then, the server broadcasts that data (once its properly checked), to the other players in the map at that same rate. Then, I use lerping in my fixed_process in Godot and it's actually starting to come along nicely. There is a tiny delay but I can increase the msgs per second for a little bit more reactiveness but it seems fine for now. Positives of this? No physics server. (A positive for me as I cannot code it!) is what I mean   Possible Negatives:  Fly hacking (although, I can try to check the difference between movements on server, but meh) Extremely bandwidth intensive? This, I don't know but I'm thinking I'm going to need to spin up more game instances, which is fine   And the server still acts as a host. It will obviously store the players last location in a variable, so when new players join the game they know where they are.    However, this means if the player (client) isn't sending those update packets to the server, sadly they will need to be disconnected. Obviously I'll give a little bit of leeway of the amount as people who lag it might disconnect them falsely That won't be a problem as anyone who is doing that, is probably fiddling around doing something dirty. Yeah, this is probably not the best way to handle this but with my knowledge the physics server will never get coded. Especially when it has to correspond to Godot's physics.   I think I am starting to grasp my head around this though.  It's probably not ideal but for a small indie game I think it'll be fine?
  6.   Oh lord, this is exactly what I was trying to convey! So glad I am getting help on this, I've always wondered how to solve it. "have a "host" managing where everyone really is". Yeah, I think I'm going to do this then. Just run some type of host server to keep track of players locations and whatnot when they give the server a command. I can mess with client prediction stuff to smooth it out, but I need to definitely kink out the host server so it's at least somewhat in sync of positions and whatnot   However, it's hard because I'm using Godot as the client side physics engine. And I'm not sure if I can replicate EXACT details of how their physics world is simulated in an actual server network code world.  Like yeah, I can use a little physics server library netcode now that will work for left,right,top,down,jumping, etc. However the gravity and all that stuff, acceleration, imply_pulse commands and stuff that I use for dynamic combat in Godot is not something I can port over to a network server. Well, I could but I'm not smart enough :P   Also, is it possible to just send the state of players to the server? This would help bigly for performance, but result in massive cheating I imagine. But then again.. That doesn't solve the problem you've stated above without a host.   I need to stop thinking that I don't need a host.. I know for a fact I need a host. Losing my damn mind  :o 
  7. Hey everyone, So I tried to make a picture showing my problem: I have a gameserver, but was curious if I need to run a physics engine on the server? I've been following some tutorials online and created some attack animations with a character and would love to create some sort of fighting online side scrolling game. I know that the client is just supposed to be a dummy sending signals to a host server, however if my host server is not created with my game engine of choice (in this case, Godot's) but (nodejs, c++, elixir, etc), would it still be possible? I just don't know how to handle lag latency compensation. For example, since the character uses set_linear_velocity with a acceleration variable... The amount of time the command actually reaches other players, will have moved the character further than his actual value. That is, if we don't have a "host" managing where everyone really is? Does this kind of make sense? I'm pretty all over the place. -- I've done simple point and click games with tweens that were multiplayer and it's fairly simple. But when the physics become involved, my brain explodes! Thanks in advance
  • 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!