summaryrefslogtreecommitdiff
path: root/Valheim_v202102/Valheim/assembly_valheim/FollowPlayer.cs
blob: d5c2992a72f4d1e06f8f7114dcaaad9e9bd38dab (plain)
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
using UnityEngine;

public class FollowPlayer : MonoBehaviour
{
	public enum Type
	{
		Player,
		Camera
	}

	public Type m_follow = Type.Camera;

	public bool m_lockYPos;

	public bool m_followCameraInFreefly;

	public float m_maxYPos = 1000000f;

	private void LateUpdate()
	{
		Camera mainCamera = Utils.GetMainCamera();
		if (!(Player.m_localPlayer == null) && !(mainCamera == null))
		{
			Vector3 zero = Vector3.zero;
			zero = ((m_follow != Type.Camera && !GameCamera.InFreeFly()) ? Player.m_localPlayer.transform.position : mainCamera.transform.position);
			if (m_lockYPos)
			{
				zero.y = base.transform.position.y;
			}
			if (zero.y > m_maxYPos)
			{
				zero.y = m_maxYPos;
			}
			base.transform.position = zero;
		}
	}
}