void Update() { //*checking speed increase works print(appleSpeed); //* makking apples fall faster this.GetComponent <Rigidbody> ().AddForce(0, -appleSpeed, 0, ForceMode.Impulse); //*rotaing the obj (aesthetics) transform.Rotate(0.5f, Random.Range(5, 10), 2f); // if an apple reaches past -20 units in the Y direction (down) if (transform.position.y < bottomY) { //Only destroy the object that this instance of the script is attached to Destroy(this.gameObject); if (this.tag == "Apple") //*added stuff - bad apple { ////**TUTORIAL CODE //reference ApplePicker script ApplePicker apScript = Camera.main.GetComponent <ApplePicker> (); ////**TUTORIAL CODE //call AppleDestroyed function in ApplePicker script apScript.AppleDestroyed(); } } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { // Get a reference to the ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); rend = GetComponent <Renderer>(); exp = GetComponent <ParticleSystem>(); // Play particle system if (!exp.isPlaying) { // There is no particle system playing if (rend.enabled) { // This is the first frame this apple is at bottomY rend.enabled = false; } else { // Particle system is done playing, destroy apple. Destroy(this); } exp.Play(); // Call the public AppleDestroyed method of apScript apScript.AppleDestroyed(); } } }
public static float bottomY = -20f; //苹果下降底线,越线销毁 private void Update() { /* * 此处可能存在的Bug: * 当第二个苹果还未实例化,第一个实例化的苹果就因下降越线被销毁,则场景内再无Apple预制体, * 则此时 AppleTree脚本 就失去对象applePrefab, * 也就是说后续AppleTree脚本内无法再实例化产生苹果; * 同理后续篮筐也可能带来同样的bug * * 解决方案:保证场景内任意时刻存在一个applePrefab * - 调高树的高度(本例方案) * - 缩短实例化苹果的间隔 * - 先隐藏再延时销毁苹果(理论可行,但感觉大材小用) */ //越线销毁,且判断到篮筐未接住 if (transform.position.y < bottomY) { Destroy(this.gameObject); //当未接住苹果时 //获取主摄像机的ApplePicker组件的引用 ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //调用apScript 的 AppleDestroyed 方法 apScript.AppleDestroyed(); } }
public static float bottomY = -20f; //safe off screen distance for apple void Update() { if (transform.position.y < bottomY) { Destroy(gameObject); //destroys apple ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //Notify Apple picker of a missed apple apScript.AppleDestroyed(); } }
void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); } }
void Update() { if (transform.position.y < appleDestroy) { Destroy(this.gameObject); ApplePicker applePicker = new ApplePicker(); applePicker.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //get a reference to the applepicker component of main camera apScript.AppleDestroyed(); } }
void Update() // Update is called once per frame { if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //Get a reference to the ApplePciker component of Main Camera apScript.AppleDestroyed(); // Call the public AppleDestroyed() method of apScript } }
void Update() { transform.position -= new Vector3(0, fallSpeed * Time.deltaTime, 0); if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // b // Call the public AppleDestroyed() method of apScript apScript.AppleDestroyed(); } }
void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); } transform.Rotate(new Vector3(-100, 0, 0) * Time.deltaTime); }
void Update() { if (transform.position.y < botomY) { Destroy(this.gameObject); //Call game controller if apple is dropped ApplePicker apScript = Camera.main.GetComponent <ApplePicker> (); apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { //kill off screen apples if (transform.position.y < bottomY) { Destroy(this.gameObject); // Get a reference to the ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // b apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); // destroy apples if it reaches bottom of the screen ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // Call the public AppleDestroyed() method of apScript apScript.AppleDestroyed(); } //end if }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); //Получити силку на компонент ApplePicker головної камери Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //Визов загального методу AppleDestroyed із apScript apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { transform.Rotate(Vector3.back * Time.deltaTime * rotationSpeed); if (transform.position.y <= bottomY) { Destroy(this.gameObject); ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); // Get a reference to the ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // Call the public AppleDestroyed() method of apScript apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); // Get a reference to the ApplePicker component of Main Camera ApplePicker appleScript = Camera.main.GetComponent <ApplePicker>(); // Call the public AppleDestroyed() method of appleScript appleScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); // Находим ссылку на ЭплПикер компонент ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // Вызываем оттуда функцию apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { //if we dropped an apple if (transform.position.y < bottomY) { Destroy(this.gameObject); //get a pointer to the ApplePicker script ApplePicker apScript = Camera.main.GetComponent <ApplePicker> (); apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < killY) { Destroy(this.gameObject); //New in Oct.06 //Notify applepicker for the death ApplePicker applePickerScript = Camera.main.GetComponent <ApplePicker>(); applePickerScript.AppleDestroyed(); } }
private void Update() { if (transform.position.y < BottomY) { Destroy(this.gameObject); //Получить ссылку на компонент ApplePicker главной камеры MainCamera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //Вызвать общедоступный метод AppleDstroye из apScript apScript.AppleDestroyed(); } }
public static float bottomY = -12f; //where the apple prefab will be destroyed void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); } //getting refernce from ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //call public AppleDestroyed() method of apScript apScript.AppleDestroyed(); }
// Update is called once per frame void Update() { //Destroy the apples when they go off screen if (transform.position.y < bottomY) { Destroy(this.gameObject); //destroys the gameobject this script is attached too ie the Apple //Notifying ApplePicker that an Apple was dropped // Get a reference to the ApplePicker component of MainCamera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); //destroy fuction removes things that are passed into it from the game //get a reference to the applepicker component of main camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //call the public appledestroyed() method of apscript apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { //this refers to the script itself. Need to clarify the gameObject. Destroy(this.gameObject); //Get a reference to the ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //Call the public AppleDestroyed() method of apScript apScript.AppleDestroyed(); } }
public static float bottomY = - 20f; // a void Update () { if ( transform.position.y < bottomY ) { Destroy( this.gameObject ); // Get a reference to the ApplePicker component of Main Camera ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); // b // Call the public AppleDestroyed() method of apScript apScript.AppleDestroyed(); // b } }
private void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); //reference applepicker ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); //call public appledestoryed method apScript.AppleDestroyed(); } }
// Update is called once per frame void Update() { if (transform.position.y < bottomY) { Destroy(this.gameObject); // Get a reference to the ApplePicker componenet ApplePicker apScript = Camera.main.GetComponent <ApplePicker>(); apScript.AppleDestroyed(); // call AppleDestoryed method in // the ApplePicker script } }