プレーヤー②(プレーヤーを動かす)
![C6db9fb2 f8a5 4296 994e 5a527b164c93](https://codegenius.org/uploads/slide/image/96/c6db9fb2-f8a5-4296-994e-5a527b164c93.jpeg)
プレーヤーを動かす
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 0.2f;
void Update()
{
float moveH = Input.GetAxis("Horizontal") * moveSpeed;
float moveV = Input.GetAxis("Vertical") * moveSpeed;
transform.Translate(moveH, 0.0f, moveV);
}
}
![4858ac15 e660 46f0 91ac c6ef5602d2f4](https://codegenius.org/uploads/slide/image/97/4858ac15-e660-46f0-91ac-c6ef5602d2f4.jpeg)
![Ed46bb37 f807 443f 8d0b 2baed73beb03](https://codegenius.org/uploads/slide/image/98/ed46bb37-f807-443f-8d0b-2baed73beb03.jpeg)
![19140c94 d243 4687 aa1b 1bcc6edbb6e2](https://codegenius.org/uploads/slide/image/99/19140c94-d243-4687-aa1b-1bcc6edbb6e2.jpeg)
プレーヤーの動きを改良する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 0.2f;
void Update()
{
// Inputの前に「-」を付ける。
float moveH = -Input.GetAxis("Horizontal") * moveSpeed;
float moveV = -Input.GetAxis("Vertical") * moveSpeed;
transform.Translate(moveH, 0.0f, moveV);
}
}
Danmaku I(基礎1/全22回)
他のコースを見る![C6db9fb2 f8a5 4296 994e 5a527b164c93](https://codegenius.org/uploads/slide/image/96/c6db9fb2-f8a5-4296-994e-5a527b164c93.jpeg)
プレーヤーを動かす
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 0.2f;
void Update()
{
float moveH = Input.GetAxis("Horizontal") * moveSpeed;
float moveV = Input.GetAxis("Vertical") * moveSpeed;
transform.Translate(moveH, 0.0f, moveV);
}
}
![4858ac15 e660 46f0 91ac c6ef5602d2f4](https://codegenius.org/uploads/slide/image/97/4858ac15-e660-46f0-91ac-c6ef5602d2f4.jpeg)
![Ed46bb37 f807 443f 8d0b 2baed73beb03](https://codegenius.org/uploads/slide/image/98/ed46bb37-f807-443f-8d0b-2baed73beb03.jpeg)
![19140c94 d243 4687 aa1b 1bcc6edbb6e2](https://codegenius.org/uploads/slide/image/99/19140c94-d243-4687-aa1b-1bcc6edbb6e2.jpeg)
プレーヤーの動きを改良する
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 0.2f;
void Update()
{
// Inputの前に「-」を付ける。
float moveH = -Input.GetAxis("Horizontal") * moveSpeed;
float moveV = -Input.GetAxis("Vertical") * moveSpeed;
transform.Translate(moveH, 0.0f, moveV);
}
}
プレーヤー②(プレーヤーを動かす)