Jump to content
  • 0

Character Direction Change


EduKrowlley

Question

Hi guys! Its me again (not Mario! :28_hugging:).

 

I'd like a system where player can change his direction without moving out of square, and started to chase the right block of code to change, I've make some changes and got this result shown on gif...

 

d8052d596381f0bc12a60663f9659212.gif

 

but! The problem is, if I open two clients and stay side by sided, when I change direction of one of the characters, the another player can't see that changes. What can I do to make these works properly? I've implemented the Running system, and its working properly, with shift + arrow (or AWSD keys) we can move faster and with control + arrow (or AWSD keys) we can turn our character direction, but I still with this problem of the direction can't be seen by another players.

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0
2 hours ago, jcsnider said:

HandleInput happens every frame, so in theory upwards of 100 times a second. You need to do your own sort of timer and only send the change when directions change and then you'll be in good shape.

 

Worked!

 

Spoiler

a92d64cbb62d307a30c9f0d2c2676608.png

 

1ad1f54d2b621c2734eadc22d7f37015.gif

 

Quote

Well, it's a good idea to see how other people did the job so you don't have to reinvent the wheel. Maybe your issue would be solved by now. Plus, when we code, we are mostly using other people codes.

 

Off course @Shenmue, with no doubt! But as I said on another post, I'm a 10+ years old programmer (Mainly Java and PHP), and started study C# only because Intersect, for me isn't a good idea to copy codes from another sources right now.

Link to comment
Share on other sites

  • 1
2 hours ago, EduKrowlley said:

 

No difference I guess. But I'm not searching for other codes, only writing mines. But thanks bytheway.

Well, it's a good idea to see how other people did the job so you don't have to reinvent the wheel. Maybe your issue would be solved by now. Plus, when we code, we are mostly using other people codes.

 

However, like JC said you must find a way to reduce the number of packets sent.

Link to comment
Share on other sites

  • 0
10 minutes ago, Joyce said:

The client doesn't send the updated direction to the server, which then doesn't pass it on to others.

I imagine that's your problem.

Yep!

 

9 minutes ago, jcsnider said:

After changing the dir add:

 

PacketSender.SendDirection(dir);

I've did this already, I've put the line PacketSender.SendDirection(dir); after the all dir changes inside of the ifs, but when I press two or three times, the account is disconnected by the server with flood reaction.

Link to comment
Share on other sites

  • 0
1 minute ago, EduKrowlley said:

Yep!

 

I've did this already, I've put the line PacketSender.SendDirection(dir); after the all dir changes inside of the ifs, but when I press two or three times, the account is disconnected by the server with flood reaction.

 

Look at these settings in the server config:

 

"FloodThreshholds": {
        "MaxPacketSize": 10240,
        "MaxPacketPerSec": 5,
        "KickAvgPacketPerSec": 3
      }

 

Link to comment
Share on other sites

  • 0
3 minutes ago, Joyce said:

 

Look at these settings in the server config:

 


"FloodThreshholds": {
        "MaxPacketSize": 10240,
        "MaxPacketPerSec": 5,
        "KickAvgPacketPerSec": 3
      }

 

 

I don't know if have another way to do that, but, I would not like to have to change that configuration... maybe anything inside of source can keep my packets cleaner? or another way to call the PacketSender that is not in every change of direction?

Link to comment
Share on other sites

  • 0
3 minutes ago, jcsnider said:

Add more logic so it only sends the direction change when the direction actually changes. On top of that.. maybe add a client side delay on how often you can change the direction? 

 

I've added this code inside of InputHandle() of the client. How often InputHandle() is called? Inside of game loop? This code are right down of the character movement inputs... :(

 

 

1c5afc5d49ee6f3bbd18919ca947947b.png

Link to comment
Share on other sites

  • 0

I believe input is handled every frame. 

 

Checking to see if you actually changed direction before sending a new one as jc suggested would probably also help. (maybe setting a cap on only being able to change directions every half a second or so as well) 

Link to comment
Share on other sites

×
×
  • Create New...