竹とんぼを作る
![8bdc1a62 a8ad 41d2 901d 30fc204b4b6c](https://codegenius.org/uploads/slide/image/2180/8bdc1a62-a8ad-41d2-901d-30fc204b4b6c.jpeg)
フラグでスイッチのOn/Offを確認する
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
public GameObject cubes;
private bool isReady = false;
void Update () {
if(Input.GetButtonDown("Fire1")){
cubes.GetComponent<Rotate>().enabled = true;
isReady = true;
}
if(Input.GetButtonDown("Jump") && isReady == true){
cubes.GetComponent<Rigidbody>().AddForce(new Vector3(-10,20,0), ForceMode.VelocityChange);
}
}
}
![2f31f45b 690d 43a0 8169 8064b3bae41d](https://codegenius.org/uploads/slide/image/2181/2f31f45b-690d-43a0-8169-8064b3bae41d.jpeg)
Unity Code Memo
他のコースを見る![8bdc1a62 a8ad 41d2 901d 30fc204b4b6c](https://codegenius.org/uploads/slide/image/2180/8bdc1a62-a8ad-41d2-901d-30fc204b4b6c.jpeg)
フラグでスイッチのOn/Offを確認する
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
public GameObject cubes;
private bool isReady = false;
void Update () {
if(Input.GetButtonDown("Fire1")){
cubes.GetComponent<Rotate>().enabled = true;
isReady = true;
}
if(Input.GetButtonDown("Jump") && isReady == true){
cubes.GetComponent<Rigidbody>().AddForce(new Vector3(-10,20,0), ForceMode.VelocityChange);
}
}
}
![2f31f45b 690d 43a0 8169 8064b3bae41d](https://codegenius.org/uploads/slide/image/2181/2f31f45b-690d-43a0-8169-8064b3bae41d.jpeg)
竹とんぼを作る