#Clients not moving

1 messages ยท Page 1 of 1 (latest)

topaz stump
#

I guess you can post your movement code here

pale wyvern
#

`using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;

public class PlayerNetwork : NetworkBehaviour {

private void Update() {
    if (!IsOwner) return;

    Vector3 moveDir = new Vector3(0, 0, 0);

    if (Input.GetKey(KeyCode.D)) moveDir.x = +1f;
    if (Input.GetKey(KeyCode.A)) moveDir.x = -1f;

    float moveSpeed = 3f;
    transform.position += moveDir * moveSpeed * Time.deltaTime;

}

}
`

#

and I just took this from the tutorial

#

except they were using 3d and im doing more of a 2d thing

topaz stump
#

nothing wrong there either. just make double sure that client actually owns the object

pale wyvern
#

I think client does but how do I check

topaz stump
#

I guess just make sure that its the player prefab or that its spawned as player object

pale wyvern
#

Ok yea I'm pretty sure client owns the object

#

Well I'm not sure what to do about it now

#

I might start over with the networking

topaz stump
#

Yea. what you posted here should just work. Something else must be effecting the transforms or stopping the player input

pale wyvern
#

I found it, there's a game controller that came with the template

edit: I removed the game controller and problem is not fixed

pale wyvern
#

@topaz stump I created an entirely new project, followed the same tutorial closely, noticed some things I didn't before, and still the client won't move

topaz stump
#

Which tutorial are you following?

pale wyvern
# topaz stump Which tutorial are you following?

๐ŸŒ Get my Complete Courses! โœ… https://unitycodemonkey.com/courses
๐Ÿ‘ Learn to make awesome games step-by-step from start to finish.
๐Ÿ‘‡ Click on Show More
๐ŸŽฎ Get my Steam Games https://unitycodemonkey.com/gamebundle

Quantum Console https://assetstore.unity.com/packages/tools/utilities/quantum-console-211046?aid=1101l96nj&pubref=ngo
FREE Third Person...

โ–ถ Play video
topaz stump
#

With the code you listed earlier, make sure that you are using client network transform instead of the regular network transform

pale wyvern
#

Like at the transform.position part?

topaz stump
#
pale wyvern
#

Oh, yeah it does

#

It has network object, the movement script, and client network transform

topaz stump
#

Is there anything else on it? Like a character controller?

pale wyvern
#

That's all

#

Wait its working now

#

I have no idea what changed

#

Actually I think I was doing the client network transform wrong, I was pasting the code into the existing network transform script, instead of creating a new script