c# - unity错误CS0201:只有assignment、call、increment、decrement、await、new object表达式可以作为语句使用
问题描述
我刚开始编程,我正在学习如何统一制作游戏的教程所以我做了一切就像视频说的那样,但我仍然收到这个错误可以请有人解释我做错了什么吗?
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);
}
}
}
解决方案
实际上,您将获得的代码是:
void Update() {
.transform.position.y, ...), directionalSpeed * ...);
}
这是无效的。这就是为什么。
推荐阅读
- pact - 当消费者 api 调用多个提供者 api 时,pact 是否支持消费者合约测试
- apache-spark - Apache Ignite Spark 集成不使用模式名称
- c# - ¤ 符号出现在文本框中而不是 $
- android - 应用更新中的 Android 应用 Play Core 库无法正常工作
- javascript - 解析包含数组数组的 json 给出“未定义”
- c++ - 声明为类字段而不是全局变量
- amazon-web-services - 如何使用 AWS CloudFormation 在 AWS API Gateway 上应用安全策略?
- jquery - 如何排除按钮被过滤?
- android - 在 Play 商店发布 Android 应用程序包有上限吗?
- django - DRF:values() 不返回 groupby 对象