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上文章的副本。我粘贴了以下内容以供参考:

试试这个:

取下你想要缩小并打破的玩家化身对象 它分为两部分:

  • 一个顶级容器对象,你可以认为是你的“逻辑化身”。这个对象的比例应该设置为(1,1,1)。会的 用于化身需要交互的任何游戏行为, 包括:

    • 托管角色控制器组件

    • 成为需要引用玩家化身的任何脚本的目标

  • 包含角色网格及其所需的任何动画组件的子“可视”对象。您可以根据需要缩放此对象 想要在不干扰物理和游戏逻辑的情况下处理 在它的上级

  • 将游戏性和对象的视觉部分分开可以给你一个 使用外观、反馈和缩放进行迭代具有更大的灵活性 不会弄乱你的物理和游戏逻辑