-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayerReporter.cs
45 lines (40 loc) · 1.18 KB
/
PlayerReporter.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using UnityEngine;
// TODO: Learn the what and *why* of C# fields vs properties
namespace DVPathTracer
{
public class PlayerReporter
{
// P = 'Player'
public const string Headings = "PPosX,PPosY,PPosZ,PRotA";
public string Values
{
get
{
return $"{Position.x},{Position.y - BaseReporter.seaLevel},{Position.z},{Rotation}";
}
}
/**
* Position in 3d space, no adjustments
*/
public Vector3 Position
{
get
{
return PlayerManager.GetWorldAbsolutePlayerPosition();
}
}
/**
* Rotation from map-North, in degrees
*/
public float Rotation
{
get
{
Transform playerTransform = PlayerManager.PlayerTransform;
Vector3 planeRotation = Vector3.ProjectOnPlane(playerTransform.forward, Vector3.up);
float rotationAngle = Mathf.Atan2(planeRotation.x, planeRotation.z) * Mathf.Rad2Deg;
return rotationAngle >= 0 ? rotationAngle : 360 + rotationAngle;
}
}
}
}