forked from RevenantX/NetGameExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemotePlayerView.cs
More file actions
29 lines (25 loc) · 807 Bytes
/
Copy pathRemotePlayerView.cs
File metadata and controls
29 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using UnityEngine;
namespace Code.Client
{
public class RemotePlayerView : MonoBehaviour, IPlayerView
{
private RemotePlayer _player;
public static RemotePlayerView Create(RemotePlayerView prefab, RemotePlayer player)
{
Quaternion rot = Quaternion.Euler(0f, player.Rotation, 0f);
var obj = Instantiate(prefab, player.Position, rot);
obj._player = player;
return obj;
}
private void Update()
{
_player.UpdatePosition(Time.deltaTime);
transform.position = _player.Position;
transform.rotation = Quaternion.Euler(0f, 0f, _player.Rotation * Mathf.Rad2Deg );
}
public void Destroy()
{
Destroy(gameObject);
}
}
}