我正在制作一个统一游戏,然后我脚本中的花括号变得愚蠢。他们都搞砸了,我不知道我做错了什么。这是我的脚本: ps:我正在使用 visual studio
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveSript : MonoBehaviour {
public GameObject myObject;
// Use this for initialization
private Vector3 direction = new Vector3(0, 0, 0);
// Update is called once per frame
private float speed = 40f;
void Start() { // error here? --> "} expected"
private Camera cam = Camera.main;
private float height = 2f * cam.orthographicSize;
private float width = height * cam.aspect;
} // i close it here, but it closes the mono beh. class instead?
void Update () {
int y = 0;
int x = 0;
if (Input.GetKey("up"))
{
y = 1;
}
if (Input.GetKey("down"))
{
y = -1;
}
if (Input.GetKey("right"))
{
x = 1;
}
if (Input.GetKey("left"))
{
x = -1;
}
direction = new Vector3(x, y, 0);
myObject.transform.position += direction.normalized*speed*Time.deltaTime;
}
}
我究竟做错了什么?感谢您的提前!
斯蒂芬大帝
慕桂英3389331
随时随地看视频慕课网APP
相关分类