lib-unity-tutorial-m2h-2-Assets-Game-3-Marble-game-Scripts-MarbleControl.cs / cs
using UnityEngine; using System.Collections; public class MarbleControl : MonoBehaviour { public float movementSpeed = 6.0f; void Update () { Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * movementSpeed) + (Input.GetAxis("Vertical") * Vector3.forward *movementSpeed); rigidbody.AddForce(movement, ForceMode.Force); } void OnTriggerEnter (Collider other ) { if (other.tag == "Pickup") { MarbleGameManager.SP.FoundGem(); Destroy(other.gameObject); } else { //Other collider.. See other.tag and other.name } } }
(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.