打开u3d创建一个空项目
然后创建一个地板terrain
把地板的X和Z的position都设置成-250
在assets文件夹下创建一个新文件夹,随便命名
再在asset文件夹下创建一个C#脚本
然后把之前建好的模型放到这个文件夹里面
创建一个新gameobject
把主角托到里面
调整相机
脚本代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class xiaoxin : MonoBehaviour {
public float speed=40;
public float rotSpeed=100;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.position += transform.forward *speed* Time.deltaTime;
if (Input.GetKey (KeyCode.A)) {
transform.Rotate (Vector3.up * Time.deltaTime * rotSpeed);
}
if (Input.GetKey (KeyCode.D)) {
transform.Rotate (Vector3.up * Time.deltaTime * (-rotSpeed));
}
}
}
<