戦車を動かす(インプットシステム)



Tankを動かす(インプットシステム)
using UnityEngine;
public class TankMovement : MonoBehaviour
{
// ★インプットシステム
private InputSystem_Actions isa;
public float moveSpeed;
public float turnSpeed;
void Start()
{
// ★インプットシステム
isa = new InputSystem_Actions();
isa.Enable();
}
void Update()
{
// ★インプットシステム
Vector2 movement2 = isa.Player.Move.ReadValue<Vector2>();
Vector3 movement3 = new Vector3(movement2.x, 0, movement2.y);
// 前進・後退
transform.Translate(Vector3.forward * movement3.z * Time.deltaTime * moveSpeed);
// 旋回
transform.Rotate(Vector3.up * movement3.x * Time.deltaTime * turnSpeed);
}
}


【Unity6版】BattleTank(全31回)
他のコースを見る


Tankを動かす(インプットシステム)
using UnityEngine;
public class TankMovement : MonoBehaviour
{
// ★インプットシステム
private InputSystem_Actions isa;
public float moveSpeed;
public float turnSpeed;
void Start()
{
// ★インプットシステム
isa = new InputSystem_Actions();
isa.Enable();
}
void Update()
{
// ★インプットシステム
Vector2 movement2 = isa.Player.Move.ReadValue<Vector2>();
Vector3 movement3 = new Vector3(movement2.x, 0, movement2.y);
// 前進・後退
transform.Translate(Vector3.forward * movement3.z * Time.deltaTime * moveSpeed);
// 旋回
transform.Rotate(Vector3.up * movement3.x * Time.deltaTime * turnSpeed);
}
}


戦車を動かす(インプットシステム)