Unityにて、ボタンを押してる間キャラの画像を切り替える
というものを作りたいんですがうまくいきません
コードはこのように書いてありました。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
[SerializeField]
float speed;
//移動ベクトル
public GameObject hensin; Vector3 velocity; // Use this for initialization IEnumerator Start() { while (true) { if (Input.GetKey(KeyCode.SpaceArrow)) { Instantiate(hensin, transform.position, transfrom.rotation); } } } // Update is called once per frame void Update() { Run(); } //ベクトル向き初期化 void Run() { velocity = Vector3.zero; //キー入力によりベクトルを加算 //左右移動 if(Input.GetKey(KeyCode.RightArrow)) { velocity.x += -speed; } if(Input.GetKey(KeyCode.LeftArrow)) { velocity.x += speed; } if(Input.GetKey(KeyCode.UpArrow)) { velocity.y += -speed; } if(Input.GetKey(KeyCode.DownArrow)) { velocity.y += speed; } transform.position -= velocity; } }
###前提・実現したいこと
ここに質問したいことを詳細に書いてください
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
###発生している問題・エラーメッセージ
エラーメッセージ
###該当のソースコード
ここにご自身が実行したソースコードを書いてください
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。