【发布时间】:2021-09-29 23:32:29
【问题描述】:
我正在学习制作游戏的教程,但是当我写他们写的东西时,它不会动。
脚本附加到精灵,但是当我点击 W、A、S 或 D 时,它没有别动。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movment : MonoBehaviour
{
// Start is called before the first frame update
public float speed = 5f;
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector2 pos = transform.position;
pos.x += h * speed * Time.deltaTime;
pos.y += v * speed * Time.deltaTime;
}
}
【问题讨论】:
标签: c# unity3d game-development