添加PlayMode一键初始化camera位置功能

修改PlayerCamera参数为private
This commit is contained in:
2024-01-09 19:18:16 +09:00
parent 173aff5137
commit 37c193ba6a
9 changed files with 356 additions and 770 deletions
@@ -261,6 +261,19 @@ public class TargetController : MonoBehaviour
sceneBlockCon.nowBlock.InitBlock(environmentObj);
}
/// <summary>
/// Spawns a scene block at a specified position.
/// </summary>
/// <param name="targetType">The type of the target, determining the type of block to generate.</param>
/// <param name="level">The level of the block, affecting its properties.</param>
/// <param name="blockNum">The number of the block, used to distinguish different blocks of the same level.</param>
/// <param name="blockPosition">The position of the block in the scene.</param>
/// <remarks>
/// This method first destroys the current block in the scene, then creates a new block based on the provided parameters and initializes it.
/// 'sceneBlockCon' is responsible for managing the creation, destruction, and initialization of scene blocks.
/// 'commonParamCon' provides additional parameters required for block creation.
/// 'environmentObj' is used during the initialization process of the block.
/// </remarks>
private void SpawnSceneBlock(Targets targetType, int level,int blockNum, Vector3 blockPosition)
{
sceneBlockCon.DestroyBlock();
+16 -9
View File
@@ -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