Unity Monodevelop中的解析错误

时间:2014-07-06 10:11:54

标签: performance

即时通讯使用unity3d monodevelop,它说我有解析错误我不知道在哪里帮忙!

这是代码

using UnityEngine;

使用System.Collections;

[RequireComponent(typeof运算(PlayerPhysics))] 公共类播放器控制器:MonoBehaviour {

// Player Handling
public float speed = 8;
public float acceleration = 30;

private float currentSpeed;
private float targetSpeed;
private Vector2 amountToMove;

private PlayerPhysics playerPhysics;


void Start () {
    playerPhysics = GetComponent<PlayerPhysics>();
}

void Update () {
    targetSpeed = Input.GetAxisRaw("Horizontal") * speed;
    currentSpeed = IncrementTowards(currentSpeed, targetSpeed,acceleration);

    if (playerPhysics.grounded) {
        amountToMove.y = 0;

    }
    playerPhysics.Move(amountToMove * Time.deltaTime);
}

// Increase n towards target by speed
private float IncrementTowards(float n, float target, float a) {
    if (n == target) {
        return n;   
    }
    else {
        float dir = Mathf.Sign(target - n); // must n be increased or decreased to get closer to target
        n += a * Time.deltaTime * dir;
        return (dir == Mathf.Sign(target-n))? n: target; // if n has now passed target then return target, otherwise return n
    }
}

}

1 个答案:

答案 0 :(得分:0)

我认为你的班级名称

[RequireComponent(typeof(PlayerPhysics))] public class Player Controller : MonoBehaviour {

导致解析错误。

尝试将其更改为:

[RequireComponent(typeof(PlayerPhysics))] public class PlayerController : MonoBehaviour {

没有空间。

更改文件名(无空格),因为它需要与类名匹配。