添加PlayMode一键初始化camera位置功能
修改PlayerCamera参数为private
This commit is contained in:
@@ -4,22 +4,23 @@ using UnityEngine;
|
||||
|
||||
public class PlayerCamera : MonoBehaviour
|
||||
{
|
||||
public float normalSpeed = 0.0035f;
|
||||
public float shiftSpeed = 0.06f;
|
||||
public float zoomSpeed = -10.0f;
|
||||
public float rotateSpeed = 0.1f;
|
||||
private float normalSpeed = 0.0035f;
|
||||
private float shiftSpeed = 0.06f;
|
||||
private float zoomSpeed = -10.0f;
|
||||
private float rotateSpeed = 0.1f;
|
||||
|
||||
public float maxHeight = 40f;
|
||||
public float minHeight = 6f;
|
||||
private float maxHeight = 40f;
|
||||
private float minHeight = 6f;
|
||||
|
||||
public Vector2 startMouseP;
|
||||
public Vector2 dragMouseP;
|
||||
private Vector2 startMouseP;
|
||||
private Vector2 dragMouseP;
|
||||
private Vector3 defaultCamPosition;
|
||||
|
||||
private float speed;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
defaultCamPosition = transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -37,6 +38,12 @@ public class PlayerCamera : MonoBehaviour
|
||||
zoomSpeed = 10.0f;
|
||||
}
|
||||
|
||||
// reset camera position
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
transform.position = defaultCamPosition;
|
||||
}
|
||||
|
||||
float hsp = transform.position.y * speed * Input.GetAxis("Horizontal"); // horizontal movement speed
|
||||
float vsp = transform.position.y * speed * Input.GetAxis("Vertical"); // vertical movement speed
|
||||
float scrollSp = Mathf.Log(transform.position.y) * -zoomSpeed * Input.GetAxis("Mouse ScrollWheel"); // scroll speed
|
||||
|
||||
Reference in New Issue
Block a user