赞助广告

 

年份

最新评论

评论 RSS

Unity调整游戏画面尺寸

clock 十一月 2, 2015 20:05 by author alex

Unity实例化游戏对象

clock 十一月 2, 2015 19:55 by author alex
using UnityEngine; using System.Collections; public class Launcher : MonoBehaviour {     public GameObject ballPrefab;     // Use this for initialization     void Start () {     }     // Update is called once per frame     void Update () {         if (Input.GetMouseButtonDown(1))         {             Instantiate(this.ballPrefab);         }     } }

Unity游戏对象跳出屏幕删除游戏对象

clock 十一月 2, 2015 15:35 by author alex
void OnCollisionEnter(Collision collision)     {         if (collision.gameObject.tag == "Floor")         {             this.is_landing = true;         }     }

unity重力加速度算法

clock 十一月 2, 2015 15:25 by author alex
public class Player : MonoBehaviour {     public float JumpHeight = 4.0f;     float jump_speed = 12.0f;     bool is_landing = false;     // Use this for initialization     void Start()     {     }     // Update is called once per frame     void Update()     {         if (this.is_landing)         {             if (Input.GetMouseButtonDown(0))             {                 is_landing = false;                 this.jump_speed = Mathf.Sqrt(2.0f * Mathf.Abs(Physics.gravity.y) * this.JumpHeight);                 this.rigidbody.velocity = Vector3.up * this.jump_speed;                 //Debug.Break();             }         }     }

Unity常用事件

clock 十月 29, 2015 20:26 by author alex
void OnBecameInvisible() 在游戏对象移动到画面之外不再被绘制时触发,通常执行 Destroy(this.gameObject)删除游戏对象。 void OnCollisionEnter(Collision collision) 游戏对象碰撞时触发

友情链接赞助