竹とんぼを作る
フラグでスイッチの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);
}
}
}
Unity Code Memo
他のコースを見るフラグでスイッチの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);
}
}
}
竹とんぼを作る