u3d

让物体沿x轴移动:transform.Translate (new Vector3 (1, 0, 0));   

              //x值为正,沿x正半轴移动;x值为负,沿x负半轴移动

让物体沿y轴移动:transform.Translate (new Vector3 (0, 1, 0));

              //y值为正,沿y正半轴移动;y值为负,沿y负半轴移动

让物体沿z轴移动:transform.Translate (new Vector3 (0, 0, 1));

               //z值为正,沿z正半轴移动;z值为负,沿z负半轴移动

让物体沿前方移动:transform.Translate (new Vector3 (forward));              //new Vector3三维

让物体沿后方移动:transform.Translate (new Vector3 (back));

让物体沿左方移动:transform.Translate (new Vector3 (left));

让物体沿右方移动:transform.Translate (new Vector3 (right));

让物体沿上方移动:transform.Translate (new Vector3 (up));

让物体沿下方移动:transform.Translate (new Vector3 (down));


让物体沿z轴旋转:   transform.Rotate (new Vector3 (0, 0,1));


让物体沿z轴增长:   transform.localScale+=(new Vector3 (0, 0, 0.1f));

创建对象

GameObject  cube=GameObject.CreatePrimitive(PrimitiveType.Cube);

克隆对象

GameObject  obj=(GameObject)Instantiate(cube);

销毁对象

Destroy(obj,1);//1是在一秒后销毁对象

1//给游戏物体添加名为FoobarScript的脚本

    GameObject.AddComponent ("FoobarScript");

2//给游戏物体添加刚体

Rigidbody rb = GameObject.AddComponent ("Rigidbody");

3//给游戏物体添加球体碰撞器

  SphereCollider  sc=GameObject.AddComponent ("SphereCollider");

常用核心类

  1)通过名称来查找:

         GameObject  player = new GameObject("Player");

        GameObject  go=GameObject.Find(“Player”);

   2)通过tag标签获取单个游戏对象:

       GameObject  go=GameObject.FindWithTag(“Player”);

    GameObject go=GameObject..FindGameObjectWithTag (“Player”);

   3)通过游戏标签获取多组游戏对象:

GameObject[]  go=GameObject.FindGameObjectsWithTag (“Player”);

Time

   按下A键,游戏物体向左移动;按下D键,游戏物体向右移动                 

                    float move_h=0;

         if (Input.GetKey (KeyCode.A)) {

               move_h-=Time.deltaTime;

         }

                   if (Input.GetKey (KeyCode.D)) {

               move_h+=Time.deltaTime;          }

  transform.Translate(new Vector3(move_h,0,move_v));


以上是数据库的初步了解,如果你有什么不会的话,可以来狗刨学习网上来看看,如果你想在Unity3D上大展手脚的话,可以来狗刨培训与专家咨询。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值