Hi all.
This may seem like a dumb question to most people, but I can’t figure out what my mistake is.
(This is probably the first time in my life that I have decided to ask for help).
What the problem is:
I recently started using “Netcode for GameObjects”.
And for the sake of testing, I decided to do a simple player move.
As I understand it, to check if a player is local or not, there is a variable: “IsLocalPlayer”
And it works but the player who is connected can’t move although islocalplayer == true
public class PlayerController : NetworkBehaviour
{
[SerializeField] private TextMeshProUGUI inputFText;
[SerializeField] private TextMeshProUGUI inputRText;
[SerializeField] private TextMeshProUGUI islocalText;
private Rigidbody _rigidbody;
private float speed =5f;
private void Awake()
{
_rigidbody = GetComponent<Rigidbody>();
}
private void Update()
{
islocalText.text = IsLocalPlayer.ToString();
if (!IsLocalPlayer)
return;
float moveF = Input.GetAxisRaw("Vertical");
float moveR = Input.GetAxisRaw("Horizontal");
inputFText.text = $"InputF: {moveF}";
inputRText.text = $"InputR: {moveR}";
Vector3 direction = transform.forward * moveF + transform.right * moveR;
_rigidbody.velocity = direction * speed;
}
}
I displayed the data of the two variables on the game screen.
And if you believe them, the player connected when you press the button responsible for: Input.GetAxisRaw(“Vertical”); ( moveF )
The variable moveF = 1 || moveF = -1 but the player does not move