C# 在编辑器中获得4个异常/错误,但可以';我不知道它们是什么?如何修复它们?
在层次结构中,我有一个作为玩家的胶囊,附带一个脚本:C# 在编辑器中获得4个异常/错误,但可以';我不知道它们是什么?如何修复它们?,c#,unity3d,C#,Unity3d,在层次结构中,我有一个作为玩家的胶囊,附带一个脚本: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float speed = 10.0f; // Update is called once per frame void Update() {
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 10.0f;
// Update is called once per frame
void Update()
{
float translatioin = Input.GetAxis("Vertical") * speed;
float straffe = Input.GetAxis("Horizontal") * speed;
translatioin *= Time.deltaTime;
straffe *= Time.deltaTime;
transform.Translate(straffe, 0, translatioin);
}
}
还有一个玩家的摄影机子项,附带了这个脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCameraMouseLook : MonoBehaviour
{
Vector2 mouseLook;
Vector2 smoothV;
public float sensitivity = 5.0f;
public float smoothing = 2.0f;
private GameObject player;
// Use this for initialization
void Start()
{
player = this.transform.parent.gameObject;
}
// Update is called once per frame
void Update()
{
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
mouseLook += smoothV;
mouseLook.y = Mathf.Clamp(mouseLook.y, -90f, 90f);
transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
player.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, Vector3.up);
}
}
当我单击编辑器中的一个错误时,它不会显示它所属的脚本。看起来像是gamedev stackexchange上文章的副本。我粘贴了以下内容以供参考: 试试这个: 取下你想要缩小并打破的玩家化身对象 它分为两部分:
- 托管角色控制器组件
- 成为需要引用玩家化身的任何脚本的目标