ボールを動かそう(インプットシステム)




ボールを動かす(インプットシステム)
using UnityEngine;
public class Ball : MonoBehaviour
{
// ★インプットシステム
private InputSystem_Actions isa;
public float moveSpeed;
private Rigidbody rb;
void Start()
{
// ★インプットシステム
isa = new InputSystem_Actions();
isa.Enable();
rb = GetComponent<Rigidbody>();
}
void Update()
{
// ★インプットシステム
Vector2 movement2 = isa.Player.Move.ReadValue<Vector2>();
Vector3 movement3 = new Vector3(movement2.x, 0, movement2.y);
rb.AddForce(movement3 * moveSpeed);
}
}




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



ボールを動かす(インプットシステム)
using UnityEngine;
public class Ball : MonoBehaviour
{
// ★インプットシステム
private InputSystem_Actions isa;
public float moveSpeed;
private Rigidbody rb;
void Start()
{
// ★インプットシステム
isa = new InputSystem_Actions();
isa.Enable();
rb = GetComponent<Rigidbody>();
}
void Update()
{
// ★インプットシステム
Vector2 movement2 = isa.Player.Move.ReadValue<Vector2>();
Vector3 movement3 = new Vector3(movement2.x, 0, movement2.y);
rb.AddForce(movement3 * moveSpeed);
}
}




ボールを動かそう(インプットシステム)