#Finneganmac mysterious static dictionaries

1 messages ยท Page 1 of 1 (latest)

raven roost
#

Also, I think it's high time we turned this into a thread.

plucky mural
#

agreed

#

please god send help

raven roost
#

Do you have Unity set up for IDE debugging?

plucky mural
#

thats the little bug in the bottom right?

raven roost
#

More than that. What IDE are you using? (Fancy text editor)

plucky mural
#

or is IDE something different

raven roost
#

Okay, so you've probably already got most of you need. Yeah, just turn on the little bug, let it recompile, then start putting stops at every step of working with the dictionaries, then press the little play button at the top of Visual Studio.

#

What you're looking for the exact point at which things go wonky.

plucky mural
#

How do you put in stops again? I have done this before I just forgot

raven roost
#

Click on the empty space to the left of the code lines.

plucky mural
#

uhhhhhh

raven roost
#

VSC, but basically the same principle.

#

When you reach a break point, VS will let you check on the state of all your variables.

plucky mural
#

I probably have to enable debugging in VS too aswell as unity dont I

raven roost
#

Did you get VS as part of Unity?

plucky mural
#

yea I have it setup to work with unity \

#

strange

#

maybe computer is haunted

raven roost
#

Do you have this button?

#

That's the play button I was referring to.

plucky mural
#

yup it says attach to unity

#

oh oh oh oh

raven roost
#

Press that, and then if it doesn't start automatically, run the game from Unity.

plucky mural
#

I just figured it out lol

#

i clicked the little one to the right of the play button and now its debugging

#

okay ill plot out the breakpoints

raven roost
#

I'ma be back in a minute. Been at this for hours, gonna grab some food.

plucky mural
#

please do, by all means you deserve it

raven roost
#

Dinner roll acquired. On that note, tangzhong is an amazing technique and the bread it makes is delicious.

plucky mural
#

noted

#

okay, so what exactly are we looking for in the breakpoints?

#

because they seem to be a pain in the ass to work with right now

raven roost
#

Hm, well first we need something to track.

#

Guess first thing to verify is whether the dictionaries are the same, or different between players.

plucky mural
#

how would we do that?

#

I can drop in my entire script if it helps lol

raven roost
#

Might as well at this point.

plucky mural
#

okay one sec

raven roost
#

You know Discord will let you drop the file in and automatically syntax highlight it?

plucky mural
#

the more you know

raven roost
#

Hm. Looks like ClientPredictionTick isn't called anywhere in this script.

plucky mural
#

Yes its called by another script that uses logic from the networking solution i chose

#

I can just zip the entire project because at this point if you have nothing else to do and are willing to go that far to help then I will

raven roost
#

Would be much better if it were a git repository. Or maybe just the scripts folder.

plucky mural
#

Ill just send the whole thing why not

#

gimme a couple minutes

raven roost
#

Please don't send the entire project via zip.

plucky mural
#

Google drive?

raven roost
#

Unity precompiles a bunch of crap with the project and it bloats the files up huge.

#

Just the assets folder or a script folder if you have it would be ideal, if you can't use git.

plucky mural
#

Okay scripts folder its is.

raven roost
#

Ah, good ol' double negative boolean. private bool dontLerp = false;

plucky mural
#

thats what amateur programming does to a man

#

theres a couple so Ill just categorize them in discord

raven roost
#

What happened to the server stuff?

#

Ohhh, you're getting spam-checked, methinks.

plucky mural
#

ye ill send again

raven roost
#

Try a zip instead.

raven roost
#

Trying very hard not to optimize while looking through this.

plucky mural
#

and dont judge my comments either

raven roost
#

My dude,
you have

#

two static dictionaries of players.

plucky mural
#

oh please god no

raven roost
#

One in Player.cs and one in PlayerManager.cs

#

Pick one, delete the other, and see what errors pop up.

plucky mural
#

oh hold on

#

I think im not smart but in a different way

#

I think I sent you the files from the client

#

I meant to only send server files

#

let me check

#

Okay so PlayerManager is a client file

#

I did not mean to send that

#

Player.cs is the correct file

#

my bad lol

raven roost
#

You may have just taught me something about dictionaries in foreach loops.

plucky mural
#

how so?

raven roost
#

foreach (Player player in Player.PlayerList.Values)
I've been using foreach(var keyValuePair in someDictoinary)

#

From which I'd have to extract the value/key if I just wanted one of them.

#

There are still a couple critical functions I can't find the callers of.
Spawn and ClientPredictionTick

plucky mural
#

they are both a part of serverhandle

#

Spawn is line 24 and ClientPredictionTick is on 19

raven roost
#

Ah, missed that one.

#

What exactly does fromClient.Id refer to?

plucky mural
#

Gets the Id of the client that sent the packet

#

it should be the same as the player Id because it goes in order by when they connetced

raven roost
#

So clientTick gets passed from a message, to ServerHandle, to Player. I can't track it earlier than that, so I don't know when it's generated.

#

My hunch is that the problem is there. The assumption that it will never generate the same number for a tick twice must be false.

#

...Though, then again, the actual bug suggests it's a different, much weirder problem.

plucky mural
#

the client sends their position at each tick up from 0

#

and it counts up every frame per player

#

which probably isnt super efficient but thats how I built it

raven roost
#

You know what, I think my early intuition was correct. I think this is a clientside problem.
Your client has two players on screen, right? Is there a guarantee it won't send ticks for both of them?

plucky mural
#

for each client to send a message per player?

#

for example if theres two players connected each client will send a packet ending up with 4 messages?

#

is that what youre suggesting is happening

#

oh

#

I think thats what is happening

#

let me change it ill see if it worksx

raven roost
plucky mural
#

Well, It appears to be working now. I seriously cant thank you enough for 3 hours of your time on Christmas eve

raven roost
#

One hour of Christmas eve.

#

Two hours Christmas, now.

plucky mural
#

the secret santa we didnt deserve

raven roost
#

But yeah, no problem. Coding is my jam, helping people with their code is also
my jam.

#

Or cranberry sauce, in this case.

plucky mural
#

a true saint

#

Seriously thank you. Have an incredible christmas and 2022

raven roost
#

And it of course all wouldn't be possible without the help of Unity

being such a trash engine >w<
'Cause I usually don't touch these channels unless I have a problem of my own. I try to return the favor for at least one person.

#

You are not that person, I just got super roped into this and wanted to figure it out.

raven roost
#

Anyway, yeah, merry christmas, glad I could help, invest in learning software architecture, try Rust lang sometime, have a good night.