首页 > 编程语言 > 详细

Unity3D 学习笔记001

时间:2019-12-22 22:01:43      阅读:133      评论:0      收藏:0      [点我收藏+]

 

//初始速度

public float movespeed = 5;

//移动   

if (Input.GetKey(KeyCode.A))

{

    go.transform.Translate(movespeed * Time.deltaTime * (-1), 0, 0, Space.World);

}

 

//开火=鼠标左键或者左ctrl

        if (Input.GetButtonDown("Fire1"))

 

//实例化 Transform (变换组件)

     Transform n = Instantiate(go, transform.position, transform.rotation);

 

//添加钢体

      Rigidbody rb = n.GetComponent<Rigidbody>();

            

 

 

//方向转换(0,0,1) forward 向前

      Vector3 fwd = transform.TransformDirection(Vector3.forward);

      rb.AddForce(fwd*30000);

 

//摧毁

      Destroy(n, 3.0f);

//镜头旋转

transform.Rotate(0, -25 * Time.deltaTime, 0, Space.Self);

 

//游戏界面 text 寻找

 

    GameObject.Find("Canvas").GetComponentInChildren<Text>().text= "弹药数量:" + m_ammo.ToString();

GameObject.Find("Text_fenshu").GetComponent<TextMesh>().text = "弹药数量:" + m_ammo.ToString();

GameObject.Find("Text_score").GetComponent<Text>().text = "2222";

 

//代码画一个 退出button

  if (GUI.Button(new Rect(180, 100, 60, 30), "退出"))

        {

            Application.Quit();

        }

 

//打印日志 用于调试

       Debug.Log("1111");

Unity3D 学习笔记001

原文:https://www.cnblogs.com/daai/p/12081251.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!