Unity通过钢体使角色移动

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {

    private Rigidbody rig;
    public float speed = 5; 

	// Use this for initialization
	void Start () {
        rig = this.GetComponent<Rigidbody>();
	}
	
	// Update is called once per frame
	void Update () {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        rig.AddForce(new Vector3(h, 0, v) * speed);
	}
}

猜你喜欢

转载自blog.csdn.net/qq_38803654/article/details/82963471