用键盘控制小球在迷宫游戏里移动
小球移动代码
using UnityEngine;
using System.Collections;
public class Shpere : MonoBehaviour
{
private Rigidbody rd;//刚体变量
public int force = 10;//力量
// Use this for initialization
void Start()
{
rd = GetComponent();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
rd.AddForce(new Vector3(h, 0, v) * 5);
}
}