我一直在尝试从这个c#脚本中获取解析错误。 请帮帮我
using UnityEngine;
using System.Collections;
public class Scripty : MonoBehaviour {
public float moveSpeed = 10f;
private Rigidbody rbody;
private Renderer rend;
// Use this for initialization
void Start () {
rbody = GetComponent<Rigidbody>();
rend = GetComponent<Renderer> ();
}
// Update is called once per frame
void Update () {
float inputX = Input.GetAxis ("Horizontal");
float inputZ = Input.GetAxis ("Vertical");
float moveX = inputX *moveSpeed*Time.deltaTime;
float moveZ = inputZ*moveSpeed*Time.deltaTime;
//transform.Translate(moveX,0f,moveZ);
rbody.AddForce(moveX,0f,moveZ);
}
void OnCollisionEnter(Collision col)
{
if (col.collider.name == "Wall (1)") {
rend.material.color = Color.blue;
}
else if(col.collider.name == "Wall (2)")
{
rend.material.color = Color.red;
}
else if(col.collider.name == "Wall (3)")
{
rend.material.color = Color.green;
}
else if(col.collider.name == "Wall (4)")
{
rend.material.color = Color.yellow;
}
}
答案 0 :(得分:2)
你最后错过了一个大括号。 setY
没有右括号。