Edits to player movemend after finishing lecture
This commit is contained in:
parent
fa8e76b3e0
commit
edc946e6ef
|
@ -21,24 +21,23 @@ public class PlayerMovement : NetworkBehaviour
|
||||||
|
|
||||||
#region Client
|
#region Client
|
||||||
|
|
||||||
[Client]
|
public override void OnStartAuthority()
|
||||||
private void OnEnable()
|
|
||||||
{
|
{
|
||||||
_navMeshAgent = GetComponent<NavMeshAgent>();
|
base.OnStartAuthority();
|
||||||
_camera = FindObjectOfType<Camera>();
|
_camera = Camera.main;
|
||||||
_mouse = Mouse.current;
|
_mouse = Mouse.current;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Client]
|
[ClientCallback]
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (_mouse.leftButton.wasPressedThisFrame)
|
if (!isOwned) return;
|
||||||
|
if (!_mouse.leftButton.wasPressedThisFrame) return;
|
||||||
|
Ray ray = _camera.ScreenPointToRay(new(_mouse.position.x.value, _mouse.position.y.value, 0));
|
||||||
|
|
||||||
|
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity))
|
||||||
{
|
{
|
||||||
Ray ray = _camera.ScreenPointToRay(new(_mouse.position.x.value, _mouse.position.y.value, 0));
|
CmdMove(hit.point);
|
||||||
if (Physics.Raycast(ray.origin, ray.direction, out RaycastHit hit, Mathf.Infinity))
|
|
||||||
{
|
|
||||||
CmdMove(hit.point);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -418,3 +418,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: dc5d69536d0782647a3de12f2d524c45, type: 3}
|
m_Script: {fileID: 11500000, guid: dc5d69536d0782647a3de12f2d524c45, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
syncDirection: 0
|
||||||
|
syncMode: 0
|
||||||
|
syncInterval: 0
|
||||||
|
_navMeshAgent: {fileID: 6135570535502036925}
|
||||||
|
|
Loading…
Reference in New Issue