1091226 角色移動
by 黃國哲 2020-12-26 07:27:16, 回應(0), 人氣(420)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class move1 : MonoBehaviour
{
// Start is called before the first frame update
public GameObject bulletprefab ;
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKey(KeyCode.A)) //往左
{transform.Translate(-0.1f,0,0);}
if(Input.GetKey(KeyCode.D)) //往右
{transform.Translate(0.1f,0,0);}
if(Input.GetKey(KeyCode.W)) //往前
{transform.Translate(0,0,0.1f);}
if(Input.GetKey(KeyCode.S)) //往後
{transform.Translate(0,0,-0.1f);}
if(Input.GetKey(KeyCode.Space)) //往上
{transform.Translate(0,0.1f,0);}
回應