lib-unity-tutorial-m2h-2-Assets-Game-1-Catch-eggs-Scripts-EggScript.cs / cs
using UnityEngine; using System.Collections; public class EggScript : MonoBehaviour { void Awake() { //rigidbody.AddForce(new Vector3(0, -100, 0), ForceMode.Force); } void Update () { float fallSpeed = 2 * Time.deltaTime; transform.position -= new Vector3(0, fallSpeed, 0); if (transform.position.y < -1 || transform.position.y >= 20) { //Destroy this gameobject (and all attached components) Destroy(gameObject); } } }
(C) Æliens 04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.