Method1:利用ASDW控制角色移动,空格跳起。
- 创建地形。
- 添加一个空的GameObject,命名改为player。再添加一个Cube和Camera作为其子物体。
- Cube中打开Mesh Renderer。
- plyer上添加Character control组件,编写脚本playermove。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 人物移动的脚本,挂载到player上
/// </summary>
public class playermove : MonoBehaviour
{
// Start is called before the first frame update
public float speed;//设定移动速度
public float jumpspeed = 5;//跳跃速度
public float g = 15;//定义重力
public</