ボールを動かそう


ボールを動かす
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Ball : MonoBehaviour { // 変数の定義(まずはこの用語を頭にインプットしましょう。) // ★↓これを記載する public float moveSpeed; private Rigidbody rb; void Start() { // ★↓これを記載する rb = GetComponent<Rigidbody>(); } void Update() { // ★↓これを記載する // HorizontalとVerticalのスペルに注意(ポイント) float moveH = Input.GetAxis("Horizontal"); float moveV = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveH, 0, moveV); rb.AddForce(movement * moveSpeed); } }
C#





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

ボールを動かす
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Ball : MonoBehaviour { // 変数の定義(まずはこの用語を頭にインプットしましょう。) // ★↓これを記載する public float moveSpeed; private Rigidbody rb; void Start() { // ★↓これを記載する rb = GetComponent<Rigidbody>(); } void Update() { // ★↓これを記載する // HorizontalとVerticalのスペルに注意(ポイント) float moveH = Input.GetAxis("Horizontal"); float moveV = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveH, 0, moveV); rb.AddForce(movement * moveSpeed); } }
C#





ボールを動かそう