unity:人物移动代码(通用式)

常用的移动代码:

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

public class Yd : MonoBehaviour
{

public float speed;

// Use this for initialization

void Start()
{

    speed = 5f;

}



// Update is called once per frame

void Update()
{

    float vertical = Input.GetAxis("Vertical");

    float horizontal = Input.GetAxis("Horizontal");

    transform.Translate(new Vector3(horizontal, 0, vertical) * Time.deltaTime * speed);
}

}

对您有帮助的话, 求给个三连吧!

你可能感兴趣的:(unity)