#Clients not moving
1 messages ยท Page 1 of 1 (latest)
`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
nothing wrong there either. just make double sure that client actually owns the object
I think client does but how do I check
I guess just make sure that its the player prefab or that its spawned as player object
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
Yea. what you posted here should just work. Something else must be effecting the transforms or stopping the player input
I found it, there's a game controller that came with the template
edit: I removed the game controller and problem is not fixed
@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
Which tutorial are you following?
https://www.youtube.com/watch?v=3yuBOB3VrCk
This one by Code Monkey
๐ 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...
With the code you listed earlier, make sure that you are using client network transform instead of the regular network transform
Like at the transform.position part?
No, your player object needs to have this component
https://docs-multiplayer.unity3d.com/netcode/current/components/networktransform#clientnetworktransform
The position, rotation, and scale of a NetworkObject is normally only synchronized once when that object is spawned. To synchronize position, rotation, and scale at realtime during the game, a NetworkTransform component is needed. NetworkTransform synchronizes the transform from server object to the clients.
Oh, yeah it does
It has network object, the movement script, and client network transform
Is there anything else on it? Like a character controller?