更新相机设置
This commit is contained in:
parent
c3058aa6a8
commit
5b39ed7377
@ -140,6 +140,7 @@ GameObject:
|
||||
- component: {fileID: 547432237}
|
||||
- component: {fileID: 547432236}
|
||||
- component: {fileID: 547432244}
|
||||
- component: {fileID: 547432245}
|
||||
m_Layer: 0
|
||||
m_Name: FlyCamera
|
||||
m_TagString: MainCamera
|
||||
@ -354,6 +355,32 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
animSpeed: 1
|
||||
--- !u!143 &547432245
|
||||
CharacterController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 547432235}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Height: 0.13
|
||||
m_Radius: 0.03
|
||||
m_SlopeLimit: 10
|
||||
m_StepOffset: 0.1
|
||||
m_SkinWidth: 0.0001
|
||||
m_MinMoveDistance: 0.001
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &555070715
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -22,11 +22,16 @@ public class FreeCameraController : MonoBehaviour
|
||||
private float yRotation = 0.0f;
|
||||
public bool isMov = true;
|
||||
public bool isRot = true;
|
||||
|
||||
CharacterController ctrlor;
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this);
|
||||
|
||||
// Cm = GameObject.Find("Mcam");
|
||||
ctrlor = GetComponent<CharacterController>();
|
||||
|
||||
|
||||
|
||||
Global.appSetting.MouseMoveSpeed.RegisterWithInitValue(v => rotateSpeed = v);
|
||||
}
|
||||
@ -53,15 +58,55 @@ public class FreeCameraController : MonoBehaviour
|
||||
{
|
||||
if (isMov)
|
||||
{
|
||||
// 相机移动
|
||||
float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
|
||||
float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
|
||||
//// 相机移动
|
||||
//float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
|
||||
//float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
|
||||
|
||||
Vector3 move = transform.right * horizontal + transform.forward * vertical;
|
||||
|
||||
transform.position += move;
|
||||
//添加相机QE上下移动功能
|
||||
transform.position+= GetInputTranslationDirection()*0.01f;
|
||||
//Vector3 move = transform.right * horizontal + transform.forward * vertical;
|
||||
|
||||
//transform.position += move;
|
||||
|
||||
|
||||
//W键前进
|
||||
if (Input.GetKey(KeyCode.W))
|
||||
{
|
||||
Vector3 forward = transform.TransformDirection(Vector3.forward);
|
||||
ctrlor.Move(forward * moveSpeed * Time.deltaTime);
|
||||
|
||||
}
|
||||
//S键后退
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
{
|
||||
Vector3 back = transform.TransformDirection(Vector3.back);
|
||||
ctrlor.Move(back * moveSpeed * Time.deltaTime);
|
||||
|
||||
}
|
||||
//A键移动
|
||||
if (Input.GetKey(KeyCode.A))
|
||||
{
|
||||
Vector3 left = transform.TransformDirection(Vector3.left);
|
||||
ctrlor.Move(left * moveSpeed * Time.deltaTime);
|
||||
}
|
||||
//D键后退
|
||||
if (Input.GetKey(KeyCode.D) && gameObject.transform.position.y > 0)
|
||||
{
|
||||
Vector3 right = transform.TransformDirection(Vector3.right);
|
||||
ctrlor.Move(right * moveSpeed * Time.deltaTime);
|
||||
}
|
||||
//E键升高
|
||||
if (Input.GetKey(KeyCode.Q))
|
||||
{
|
||||
Vector3 upward = transform.TransformDirection(Vector3.up);
|
||||
ctrlor.Move(upward * moveSpeed * Time.deltaTime);
|
||||
}
|
||||
//E键升高
|
||||
if (Input.GetKey(KeyCode.E))
|
||||
{
|
||||
Vector3 down = transform.TransformDirection(Vector3.down);
|
||||
ctrlor.Move(down * moveSpeed * Time.deltaTime);
|
||||
}
|
||||
////添加相机QE上下移动功能
|
||||
//transform.position+= GetInputTranslationDirection()*0.01f;
|
||||
|
||||
}
|
||||
if (isRot)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user