25 lines
710 B
C#
25 lines
710 B
C#
using System;
|
|
using FishNet.Object;
|
|
using UnityEngine;
|
|
|
|
namespace Players
|
|
{
|
|
public sealed class PlayerMoving : NetworkBehaviour
|
|
{
|
|
[SerializeField] private float _moveSpeed = 5f;
|
|
[SerializeField] private CharacterController _characterController;
|
|
|
|
private void Update()
|
|
{
|
|
if (!IsOwner)
|
|
return;
|
|
|
|
float horizontal = Input.GetAxisRaw("Horizontal");
|
|
float vertical = Input.GetAxisRaw("Vertical");
|
|
|
|
Vector3 offset = new Vector3(horizontal, Physics.gravity.y, vertical).normalized * (_moveSpeed * Time.deltaTime);
|
|
|
|
_characterController.Move(offset);
|
|
}
|
|
}
|
|
} |