C#——实现物体的移动(unity)

    xiaoxiao2023-03-24  5

    using UnityEngine;

    using System.Collections;

    public class shiftTest: MonoBehaviour {

    public flooat speed;

    float AD;

    floatWS;

    void Update(){

    AD = Input.GetAxis("Horizontal");//横轴

    WS = Input.getAxis("Vertical");//纵轴

    this.gameObject.transform.Translate(new Vector3(AD * speed,0,WS * speed)); //一句话完成移动控制(这里只管我们游戏对象的前后左右移动)  里边是我们传入的方向

    转载请注明原文地址: https://ju.6miu.com/read-1202570.html
    最新回复(0)