Unity错误CS0201:只能将赋值,调用,递增,递减,等待和新对象表达式用作语句

时间:2019-12-15 17:10:02

标签: c# unity3d

我刚刚开始编程,现在正在学习有关如何统一制作游戏的教程 所以我做了所有的事情,就像视频说的那样,但是我仍然遇到这个错误 能不能请别人解释我做错了什么?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{

    public float playerSpeed = 500;
    public float directionalSpeed = 20;

    void Start()
    {
       // Start is called before the first frame update            
    }

    // Update is called once per frame
    void Update() {
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        .transform.position.y, gameObject.transform.position.z), directionalSpeed * Time.deltaTime);
#endif
        float moveHorizontal = Input.GetAxis("Horizontal");
        transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(Mathf.Clamp(gameObject.transform.position.x + moveHorizontal, -2.5f, 2.5f), gameObject
        GetComponent<Rigidbody>().velocity = Vector3.forward * playerSpeed * Time.deltaTime;
        //Mobile Controls
        Vector2 touch = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 10f));
        if (Input.touchCount > 0)
        {    
           transform.position + new Vector3(touch.x, transform.position.y, transform.position.z);            
        }     
    }
}

1 个答案:

答案 0 :(得分:0)

实际上,您将获得的代码是:

void Update() {
.transform.position.y, ...), directionalSpeed * ...);
}

这是无效的。那就是为什么。