July 10, 2012 · 0 Comments
using UnityEngine; using System.Collections; public class control : MonoBehaviour { public GameObject m_gameoject; // Use this for initialization void Start () { } void Update () { float translation = Input.GetAxis("Horizontal") ; transform.Translate(translation, 0, 0); if (Input.GetButtonUp("Fire1") ) { m_gameoject.rigidbody.AddForce (Vector3.up * 300); } } void OnCollisionEnter (Collision other ) { other.rigidbody.AddForce (Vector3.up * 300); } }