#this is done with a serverrpc modifying

1 messages ยท Page 1 of 1 (latest)

thorn iron
#

Post the full code here and we can see whats up

hollow patrol
#

goodness

#

the code is garbodor

#

welp

#

one moment ig

vivid flax
hollow patrol
#

๐Ÿ’€

#

ok the script is too big

#

but i can do pseudocode

vivid flax
#

dont do pseudocode

hollow patrol
#

i can't send it tho

#

its too thicc

vivid flax
#

strip out the parts of the script that are relevant to the issue

hollow patrol
#

ik

#

i am

#

i have a crap way of doing the things im doing

#

hold on

#

yall aint gonna like this

#

but here you are:

#
using UnityEngine;
using Unity.Netcode;

class WASDMovement : NetworkBehaviour
{
public NetworkVariable<bool> A;
public NetworkVariable<bool> W;
public NetworkVariable<bool> S;
public NetworkVariable<bool> D;
public NetworkVariable<bool> SpacePressed;
public NetworkVariable<float> Orientaiton;

void Update()
{
OrientServerRpc();

if (Input.GetKeyDown(KeyCode.W))
{
SendServerRpc(true, 'W');
}
if (Input.GetKeyDown(KeyCode.A))
{
SendServerRpc(true, 'A');
}
if (Input.GetKeyDown(KeyCode.S))
{
SendServerRpc(true, 'S');
}
if (Input.GetKeyDown(KeyCode.D))
{
SendServerRpc(true, 'D');
}
if (Input.GetKeyUp(KeyCode.W))
{
SendServerRpc(false, 'W');
}
if (Input.GetKeyUp(KeyCode.A))
{
SendServerRpc(false, 'A');
}
if (Input.GetKeyUp(KeyCode.S))
{
SendServerRpc(false, 'S');
}
if (Input.GetKeyUp(KeyCode.D))
{
SendServerRpc(false, 'D');
}
if (Input.GetKeyDown(KeyCode.Space))
{
SendServerRpc(true, '_',);
}
else
{
SendServerRpc(false, '_');
}
}

[ServerRpc]
private void SendServerRpc(bool a, char b)
{
if (a)
{
switch (b)
{
case 'W':
W.Value = true;
break;
case 'A':
A.Value = true;
break;
case 'S':
S.Value = true;
break;
case 'D':
D.Value = true;
break;
case '_':
SpacePressed.Value = true;
break;
}
}
else
{
switch (b)
{
case 'W':
W.Value = false;
break;
case 'A':
A.Value = false;
break;
case 'S':
S.Value = false;
break;
case 'D':
D.Value = false;
break;
case '_':
SpacePressed.Value = false;
break;
}
}
}
[ServerRpc]
void OrientServerRpc()
{
Orientaiton.Value++;
}
}
#

@thorn iron @vivid flax here you guys are

#

=)

#

WAIT

#

I GOT it

#

ALL OF A SUDDEN

#

NOW ITS WORKING

#

WHY?

#

BECAUSE BEFORE

#

I WAS USING INPUT.GETAXIS

#

ON THE EI)(!#%_(U$*ING SERVER!

#

WHICH IS WHY THE SERVER/HOST TOOK CONTROL IN THE FIRST PLACE

hollow patrol
#

also

#

the rpcs are completely fine